Reading Profiles (#3845)
Co-authored-by: Joseph Milazzo <joseph.v.milazzo@gmail.com>
This commit is contained in:
parent
ea28d64302
commit
1856b01a46
67 changed files with 8118 additions and 1159 deletions
|
@ -275,13 +275,12 @@ public class AutoMapperProfiles : Profile
|
|||
CreateMap<AppUserPreferences, UserPreferencesDto>()
|
||||
.ForMember(dest => dest.Theme,
|
||||
opt =>
|
||||
opt.MapFrom(src => src.Theme))
|
||||
opt.MapFrom(src => src.Theme));
|
||||
|
||||
CreateMap<AppUserReadingProfile, UserReadingProfileDto>()
|
||||
.ForMember(dest => dest.BookReaderThemeName,
|
||||
opt =>
|
||||
opt.MapFrom(src => src.BookThemeName))
|
||||
.ForMember(dest => dest.BookReaderLayoutMode,
|
||||
opt =>
|
||||
opt.MapFrom(src => src.BookReaderLayoutMode));
|
||||
opt.MapFrom(src => src.BookThemeName));
|
||||
|
||||
|
||||
CreateMap<AppUserBookmark, BookmarkDto>();
|
||||
|
|
|
@ -21,7 +21,7 @@ public class AppUserBuilder : IEntityBuilder<AppUser>
|
|||
ApiKey = HashUtil.ApiKey(),
|
||||
UserPreferences = new AppUserPreferences
|
||||
{
|
||||
Theme = theme ?? Seed.DefaultThemes.First()
|
||||
Theme = theme ?? Seed.DefaultThemes.First(),
|
||||
},
|
||||
ReadingLists = new List<ReadingList>(),
|
||||
Bookmarks = new List<AppUserBookmark>(),
|
||||
|
@ -31,7 +31,8 @@ public class AppUserBuilder : IEntityBuilder<AppUser>
|
|||
Devices = new List<Device>(),
|
||||
Id = 0,
|
||||
DashboardStreams = new List<AppUserDashboardStream>(),
|
||||
SideNavStreams = new List<AppUserSideNavStream>()
|
||||
SideNavStreams = new List<AppUserSideNavStream>(),
|
||||
ReadingProfiles = [],
|
||||
};
|
||||
}
|
||||
|
||||
|
|
54
API/Helpers/Builders/AppUserReadingProfileBuilder.cs
Normal file
54
API/Helpers/Builders/AppUserReadingProfileBuilder.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue