Cleanup of lazy loading code. Made some DTOs use init rather than set to keep it clean.

This commit is contained in:
Joseph Milazzo 2021-03-12 13:20:08 -06:00
parent 33515ad865
commit af35d8aad5
18 changed files with 103 additions and 68 deletions

View file

@ -4,28 +4,27 @@ namespace API.DTOs
{
public class ChapterDto
{
public int Id { get; set; }
public int Id { get; init; }
/// <summary>
/// Range of chapters. Chapter 2-4 -> "2-4". Chapter 2 -> "2".
/// </summary>
public string Range { get; set; }
public string Range { get; init; }
/// <summary>
/// Smallest number of the Range.
/// </summary>
public string Number { get; set; }
//public byte[] CoverImage { get; set; }
public string Number { get; init; }
/// <summary>
/// Total number of pages in all MangaFiles
/// </summary>
public int Pages { get; set; }
public int Pages { get; init; }
/// <summary>
/// The files that represent this Chapter
/// </summary>
public ICollection<MangaFileDto> Files { get; set; }
public ICollection<MangaFileDto> Files { get; init; }
/// <summary>
/// Calculated at API time. Number of pages read for this Chapter for logged in user.
/// </summary>
public int PagesRead { get; set; }
public int VolumeId { get; set; }
public int VolumeId { get; init; }
}
}

View file

@ -7,11 +7,11 @@ namespace API.DTOs
public class CreateLibraryDto
{
[Required]
public string Name { get; set; }
public string Name { get; init; }
[Required]
public LibraryType Type { get; set; }
public LibraryType Type { get; init; }
[Required]
[MinLength(1)]
public IEnumerable<string> Folders { get; set; }
public IEnumerable<string> Folders { get; init; }
}
}

View file

@ -2,14 +2,14 @@
{
public class ImageDto
{
public int Page { get; set; }
public int Page { get; init; }
public string Filename { get; init; }
public string FullPath { get; init; }
public int Width { get; init; }
public int Height { get; init; }
public string Format { get; init; }
public byte[] Content { get; init; }
public string MangaFileName { get; set; }
public bool NeedsSplitting { get; set; }
public string MangaFileName { get; init; }
public bool NeedsSplitting { get; init; }
}
}

View file

@ -6,9 +6,9 @@ namespace API.DTOs
public class LibraryDto
{
public int Id { get; init; }
public string Name { get; set; }
public string CoverImage { get; set; }
public LibraryType Type { get; set; }
public ICollection<string> Folders { get; set; }
public string Name { get; init; }
public string CoverImage { get; init; }
public LibraryType Type { get; init; }
public ICollection<string> Folders { get; init; }
}
}

View file

@ -2,7 +2,7 @@
{
public class LoginDto
{
public string Username { get; set; }
public string Password { get; set; }
public string Username { get; init; }
public string Password { get; init; }
}
}

View file

@ -4,9 +4,9 @@ namespace API.DTOs
{
public class MangaFileDto
{
public string FilePath { get; set; }
public int NumberOfPages { get; set; } // TODO: Refactor to Pages
public MangaFormat Format { get; set; }
public string FilePath { get; init; }
public int NumberOfPages { get; init; }
public MangaFormat Format { get; init; }
}
}

View file

@ -2,6 +2,6 @@
{
public class MarkReadDto
{
public int SeriesId { get; set; }
public int SeriesId { get; init; }
}
}

View file

@ -8,11 +8,11 @@ namespace API.DTOs
/// </summary>
public class MemberDto
{
public int Id { get; set; }
public string Username { get; set; }
public DateTime Created { get; set; }
public DateTime LastActive { get; set; }
public IEnumerable<LibraryDto> Libraries { get; set; }
public IEnumerable<string> Roles { get; set; }
public int Id { get; init; }
public string Username { get; init; }
public DateTime Created { get; init; }
public DateTime LastActive { get; init; }
public IEnumerable<LibraryDto> Libraries { get; init; }
public IEnumerable<string> Roles { get; init; }
}
}

View file

@ -5,10 +5,10 @@ namespace API.DTOs
public class RegisterDto
{
[Required]
public string Username { get; set; }
public string Username { get; init; }
[Required]
[StringLength(16, MinimumLength = 4)]
public string Password { get; set; }
public bool IsAdmin { get; set; }
public string Password { get; init; }
public bool IsAdmin { get; init; }
}
}

View file

@ -6,8 +6,8 @@
public string Name { get; init; }
public string OriginalName { get; init; }
public string SortName { get; init; }
public byte[] CoverImage { get; init; } // This should be optional or a thumbImage (much smaller)
public byte[] CoverImage { get; init; } // This should be optional or a thumbImage (much smaller) // TODO: Refactor to lazy loading
public string CoverImageUrl { get; init; }
// Grouping information
public string LibraryName { get; set; }

View file

@ -8,7 +8,6 @@
public string LocalizedName { get; init; }
public string SortName { get; init; }
public string Summary { get; init; }
public byte[] CoverImage { get; init; }
public int Pages { get; init; }
/// <summary>
/// Sum of pages read from linked Volumes. Calculated at API-time.

View file

@ -9,7 +9,6 @@ namespace API.DTOs
public int Id { get; set; }
public int Number { get; set; }
public string Name { get; set; }
//public byte[] CoverImage { get; set; }
public int Pages { get; set; }
public int PagesRead { get; set; }
public DateTime LastModified { get; set; }