Kavita/API/Helpers/Builders/ChapterBuilder.cs
Joe Milazzo bd19b282d5
Misc Fixes + Enhancements (#1875)
* Moved Collapse Series with relationships into a user preference rather than library setting.

* Fixed bookmarks not converting to webp after initial save

* Fixed a bug where when merging we'd print out a duplicate series error when we shouldn't have

* Fixed a bug where clicking on a genre or tag from server stats wouldn't load all-series page in a filtered state.

* Implemented the ability to have Login role and thus disable accounts.

* Ensure first time flow gets the Login role

* Refactored user management screen so that pending users can be edited or deleted before the end user accepts the invite. A side effect is old legacy users that were here before email was required can now be deleted.

* Show a progress bar under the main series image on larger viewports to show whole series progress.

* Removed code no longer needed

* Cleanup tags, people, collections without connections after editing series metadata.

* Moved the Entity Builders to the main project
2023-03-10 17:09:38 -08:00

58 lines
1.4 KiB
C#

using System.Collections.Generic;
using API.Entities;
using API.Entities.Enums;
namespace API.Helpers.Builders;
public class ChapterBuilder : IEntityBuilder<Chapter>
{
private readonly Chapter _chapter;
public Chapter Build() => _chapter;
public ChapterBuilder(string number, string? range=null)
{
_chapter = new Chapter()
{
Range = string.IsNullOrEmpty(range) ? number : range,
Title = string.IsNullOrEmpty(range) ? number : range,
Number = API.Services.Tasks.Scanner.Parser.Parser.MinNumberFromRange(number) + string.Empty,
Files = new List<MangaFile>(),
Pages = 1
};
}
public ChapterBuilder WithAgeRating(AgeRating rating)
{
_chapter.AgeRating = rating;
return this;
}
public ChapterBuilder WithPages(int pages)
{
_chapter.Pages = pages;
return this;
}
public ChapterBuilder WithCoverImage(string cover)
{
_chapter.CoverImage = cover;
return this;
}
public ChapterBuilder WithIsSpecial(bool isSpecial)
{
_chapter.IsSpecial = isSpecial;
return this;
}
public ChapterBuilder WithTitle(string title)
{
_chapter.Title = title;
return this;
}
public ChapterBuilder WithFile(MangaFile file)
{
_chapter.Files ??= new List<MangaFile>();
_chapter.Files.Add(file);
return this;
}
}