mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-19 21:44:16 -04:00
* 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
72 lines
1.7 KiB
C#
72 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using API.Entities;
|
|
using API.Entities.Enums;
|
|
using API.Entities.Metadata;
|
|
using API.Extensions;
|
|
|
|
namespace API.Helpers.Builders;
|
|
|
|
public class SeriesBuilder : IEntityBuilder<Series>
|
|
{
|
|
private readonly Series _series;
|
|
public Series Build()
|
|
{
|
|
_series.Pages = _series.Volumes.Sum(v => v.Chapters.Sum(c => c.Pages));
|
|
return _series;
|
|
}
|
|
|
|
public SeriesBuilder(string name)
|
|
{
|
|
_series = new Series()
|
|
{
|
|
Name = name,
|
|
LocalizedName = name.ToNormalized(),
|
|
OriginalName = name,
|
|
SortName = name,
|
|
NormalizedName = name.ToNormalized(),
|
|
NormalizedLocalizedName = name.ToNormalized(),
|
|
Metadata = new SeriesMetadata(),
|
|
Volumes = new List<Volume>()
|
|
};
|
|
}
|
|
|
|
public SeriesBuilder WithLocalizedName(string localizedName)
|
|
{
|
|
_series.LocalizedName = localizedName;
|
|
_series.NormalizedLocalizedName = localizedName.ToNormalized();
|
|
return this;
|
|
}
|
|
|
|
public SeriesBuilder WithFormat(MangaFormat format)
|
|
{
|
|
_series.Format = format;
|
|
return this;
|
|
}
|
|
|
|
public SeriesBuilder WithVolume(Volume volume)
|
|
{
|
|
_series.Volumes ??= new List<Volume>();
|
|
_series.Volumes.Add(volume);
|
|
return this;
|
|
}
|
|
|
|
public SeriesBuilder WithVolumes(List<Volume> volumes)
|
|
{
|
|
_series.Volumes = volumes;
|
|
return this;
|
|
}
|
|
|
|
public SeriesBuilder WithMetadata(SeriesMetadata metadata)
|
|
{
|
|
_series.Metadata = metadata;
|
|
return this;
|
|
}
|
|
|
|
public SeriesBuilder WithPages(int pages)
|
|
{
|
|
_series.Pages = pages;
|
|
return this;
|
|
}
|
|
}
|