mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-23 15:30:34 -04:00
55 lines
1.3 KiB
C#
55 lines
1.3 KiB
C#
using API.Entities;
|
|
using API.Entities.Enums;
|
|
using API.Extensions;
|
|
|
|
namespace API.Helpers.Builders;
|
|
|
|
public class AppUserReadingProfileBuilder
|
|
{
|
|
private readonly AppUserReadingProfile _profile;
|
|
|
|
public AppUserReadingProfile Build() => _profile;
|
|
|
|
/// <summary>
|
|
/// The profile's kind will be <see cref="ReadingProfileKind.User"/> unless overwritten with <see cref="WithKind"/>
|
|
/// </summary>
|
|
/// <param name="userId"></param>
|
|
public AppUserReadingProfileBuilder(int userId)
|
|
{
|
|
_profile = new AppUserReadingProfile
|
|
{
|
|
AppUserId = userId,
|
|
Kind = ReadingProfileKind.User,
|
|
SeriesIds = [],
|
|
LibraryIds = []
|
|
};
|
|
}
|
|
|
|
public AppUserReadingProfileBuilder WithSeries(Series series)
|
|
{
|
|
_profile.SeriesIds.Add(series.Id);
|
|
return this;
|
|
}
|
|
|
|
public AppUserReadingProfileBuilder WithLibrary(Library library)
|
|
{
|
|
_profile.LibraryIds.Add(library.Id);
|
|
return this;
|
|
}
|
|
|
|
public AppUserReadingProfileBuilder WithKind(ReadingProfileKind kind)
|
|
{
|
|
_profile.Kind = kind;
|
|
return this;
|
|
}
|
|
|
|
public AppUserReadingProfileBuilder WithName(string name)
|
|
{
|
|
_profile.Name = name;
|
|
_profile.NormalizedName = name.ToNormalized();
|
|
return this;
|
|
}
|
|
|
|
|
|
}
|