Fix Unit Tests

This commit is contained in:
Amelia 2025-04-26 20:29:46 +02:00
parent f29c63c6c4
commit 749fb24185
No known key found for this signature in database
GPG key ID: D6D0ECE365407EAA
7 changed files with 219 additions and 178 deletions

View file

@ -13,7 +13,13 @@ namespace API.Services;
public interface IRatingService
{
Task<bool> UpdateRating(int userId, UpdateRatingDto updateRatingDto);
/// <summary>
///
/// </summary>
/// <param name="user">Should include ratings</param>
/// <param name="updateRatingDto"></param>
/// <returns></returns>
Task<bool> UpdateRating(AppUser user, UpdateRatingDto updateRatingDto);
}
public class RatingService: IRatingService
@ -30,17 +36,8 @@ public class RatingService: IRatingService
_logger = logger;
}
/// <summary>
///
/// </summary>
/// <param name="userId"></param>
/// <param name="updateRatingDto"></param>
/// <returns></returns>
public async Task<bool> UpdateRating(int userId, UpdateRatingDto updateRatingDto)
public async Task<bool> UpdateRating(AppUser user, UpdateRatingDto updateRatingDto)
{
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(userId, AppUserIncludes.Ratings);
if (user == null) throw new UnauthorizedAccessException();
var userRating =
await _unitOfWork.UserRepository.GetUserRatingAsync(updateRatingDto.SeriesId, user.Id, updateRatingDto.ChapterId) ??
new AppUserRating();