Load, save, and delete chapter reviews
This commit is contained in:
parent
a3e04f3bc1
commit
85b6f107bc
13 changed files with 192 additions and 13 deletions
50
API/Helpers/Builders/ChapterRatingBuilder.cs
Normal file
50
API/Helpers/Builders/ChapterRatingBuilder.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using API.Entities;
|
||||
|
||||
namespace API.Helpers.Builders;
|
||||
|
||||
#nullable enable
|
||||
public class ChapterRatingBuilder
|
||||
{
|
||||
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 WithVolumeId(int volumeId)
|
||||
{
|
||||
_rating.VolumeId = volumeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChapterRatingBuilder WithRating(int rating)
|
||||
{
|
||||
_rating.Rating = Math.Clamp(rating, 0, 5);
|
||||
_rating.HasBeenRated = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChapterRatingBuilder WithReview(string review)
|
||||
{
|
||||
_rating.Review = review;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue