mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
41 lines
926 B
C#
41 lines
926 B
C#
#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;
|
|
}
|
|
}
|