Kavita/API/Helpers/Builders/VolumeBuilder.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

44 lines
961 B
C#

using System.Collections.Generic;
using System.Linq;
using API.Data;
using API.Entities;
namespace API.Helpers.Builders;
public class VolumeBuilder : IEntityBuilder<Volume>
{
private readonly Volume _volume;
public Volume Build() => _volume;
public VolumeBuilder(string volumeNumber)
{
_volume = DbFactory.Volume(volumeNumber);
}
public VolumeBuilder WithName(string name)
{
_volume.Name = name;
return this;
}
public VolumeBuilder WithNumber(int number)
{
_volume.Number = number;
return this;
}
public VolumeBuilder WithChapters(List<Chapter> chapters)
{
_volume.Chapters = chapters;
return this;
}
public VolumeBuilder WithChapter(Chapter chapter)
{
_volume.Chapters ??= new List<Chapter>();
_volume.Chapters.Add(chapter);
_volume.Pages = _volume.Chapters.Sum(c => c.Pages);
return this;
}
}