fixed errors and finish endpoints

This commit is contained in:
2026-03-09 23:24:01 +01:00
parent 679c552a3f
commit 756382a496
8 changed files with 124 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ using BookHive.Models;
using BookHive.Repositories;
using BookHive.Specifications.Books;
using BookHive.Specifications.Members;
using BookHive.Specifications.Reviews;
using FastEndpoints;
namespace BookHive.Endpoints.Reviews;
@@ -36,6 +37,19 @@ public class CreateReviewEndpoint(
return;
}
if (!member.IsActive)
{
await Send.StringAsync("Le membre est désactivé", 400, cancellation: ct);
return;
}
Review? review = await reviewRepository.SingleOrDefaultAsync(new GetReviewByCriteriaSpec(req.BookId, req.MemberId), ct);
if (review is not null)
{
await Send.StringAsync("Le membre a déjà posté un commentaire", 400, cancellation: ct);
return;
}
await reviewRepository.AddAsync(mapper.Map<Review>(req), ct);
await Send.OkAsync(cancellation: ct);
}