Extract enum for later use

This commit is contained in:
Amelia 2025-04-26 00:42:43 +02:00
parent 114ee4f09b
commit e96cb0fde9
No known key found for this signature in database
GPG key ID: D6D0ECE365407EAA
5 changed files with 22 additions and 13 deletions

View file

@ -3,6 +3,7 @@ using System.Threading.Tasks;
using API.Data;
using API.Data.Repositories;
using API.DTOs.SeriesDetail;
using API.Entities.Enums;
using API.Extensions;
using API.Helpers.Builders;
using API.Services.Plus;
@ -86,6 +87,7 @@ public class ReviewController : BaseApiController
.WithChapterId(chapter.Id)
.WithRating(dto.Rating)
.WithReview(dto.Body)
.WithProvider(RatingProvider.Kavita)
.Build();
if (rating.Id == 0)

View file

@ -1,26 +1,16 @@
using API.Services.Plus;
using API.Entities.Enums;
namespace API.Entities;
#nullable enable
public enum ChapterRatingProvider
{
Kavita = 0,
AniList = 1,
Mal = 2,
CbrUser = 3,
CbrCritic = 4,
}
public class AppUserChapterRating
{
public int Id { get; set; }
public float Rating { get; set; }
public bool HasBeenRated { get; set; }
public string? Review { get; set; }
public ChapterRatingProvider Provider {get; set; }
public RatingProvider Provider {get; set; }
public int SeriesId { get; set; }
public Series Series { get; set; } = null!;

View file

@ -0,0 +1,10 @@
namespace API.Entities.Enums;
public enum RatingProvider
{
Kavita = 0,
AniList = 1,
Mal = 2,
CbrUser = 3,
CbrCritic = 4,
}

View file

@ -1,5 +1,6 @@
using System;
using API.Entities;
using API.Entities.Enums;
namespace API.Helpers.Builders;
@ -46,5 +47,11 @@ public class ChapterRatingBuilder
return this;
}
public ChapterRatingBuilder WithProvider(RatingProvider provider)
{
_rating.Provider = provider;
return this;
}
}

View file

@ -30,7 +30,7 @@ namespace API.Services.Plus;
/// <summary>
/// Misleading name but is the source of data (like a review coming from AniList)
/// </summary>
/// <remarks>Keep <see cref="ChapterRatingProvider"/> in sync</remarks>
/// <remarks>Keep <see cref="RatingProvider"/> in sync</remarks>
public enum ScrobbleProvider
{
/// <summary>