fixed errors and finish endpoints
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user