More Testing (#2683)

This commit is contained in:
Joe Milazzo 2024-02-02 17:12:37 -06:00 committed by GitHub
parent 4ce2b4343a
commit 685f7365e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 168 additions and 36 deletions

View file

@ -61,4 +61,23 @@ public class ReviewController : BaseApiController
_scrobblingService.ScrobbleReviewUpdate(user.Id, dto.SeriesId, string.Empty, dto.Body));
return Ok(_mapper.Map<UserReviewDto>(rating));
}
/// <summary>
/// Deletes the user's review for the given series
/// </summary>
/// <returns></returns>
[HttpDelete]
public async Task<ActionResult> DeleteReview(int seriesId)
{
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(User.GetUserId(), AppUserIncludes.Ratings);
if (user == null) return Unauthorized();
user.Ratings = user.Ratings.Where(r => r.SeriesId != seriesId).ToList();
_unitOfWork.UserRepository.Update(user);
await _unitOfWork.CommitAsync();
return Ok();
}
}