Chapter/Issue level Reviews and Ratings (#3778)

Co-authored-by: Joseph Milazzo <josephmajora@gmail.com>
This commit is contained in:
Fesaa 2025-04-29 18:53:24 +02:00 committed by GitHub
parent 3b8997e46e
commit 4f7625ea77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
60 changed files with 5097 additions and 497 deletions

View file

@ -97,6 +97,16 @@ public class AutoMapperProfiles : Profile
.ForMember(dest => dest.Username,
opt =>
opt.MapFrom(src => src.AppUser.UserName));
CreateMap<AppUserChapterRating, UserReviewDto>()
.ForMember(dest => dest.LibraryId,
opt =>
opt.MapFrom(src => src.Series.LibraryId))
.ForMember(dest => dest.Body,
opt =>
opt.MapFrom(src => src.Review))
.ForMember(dest => dest.Username,
opt =>
opt.MapFrom(src => src.AppUser.UserName));
CreateMap<AppUserProgress, ProgressDto>()
.ForMember(dest => dest.PageNum,

View file

@ -0,0 +1,40 @@
#nullable enable
using System;
using API.Entities;
namespace API.Helpers.Builders;
public class ChapterRatingBuilder : IEntityBuilder<AppUserChapterRating>
{
private readonly AppUserChapterRating _rating;
public AppUserChapterRating Build() => _rating;
public ChapterRatingBuilder(AppUserChapterRating? rating = null)
{
_rating = rating ?? new AppUserChapterRating();
}
public ChapterRatingBuilder WithSeriesId(int seriesId)
{
_rating.SeriesId = seriesId;
return this;
}
public ChapterRatingBuilder WithChapterId(int chapterId)
{
_rating.ChapterId = chapterId;
return this;
}
public ChapterRatingBuilder WithRating(int rating)
{
_rating.Rating = Math.Clamp(rating, 0, 5);
return this;
}
public ChapterRatingBuilder WithBody(string body)
{
_rating.Review = body;
return this;
}
}