Cleaned code

This commit is contained in:
2026-03-17 10:27:53 +01:00
parent 15075eb051
commit d202d1541d
55 changed files with 306 additions and 264 deletions

View File

@@ -9,9 +9,9 @@ using FastEndpoints;
namespace BookHive.Endpoints.Reviews;
public class CreateReviewEndpoint(
ReviewRepository reviewRepository,
MemberRepository memberRepository,
BookRepository bookRepository,
ReviewRepository reviewRepository,
MemberRepository memberRepository,
BookRepository bookRepository,
AutoMapper.IMapper mapper)
: Endpoint<CreateReviewDto>
{
@@ -29,14 +29,14 @@ public class CreateReviewEndpoint(
await Send.NotFoundAsync(ct);
return;
}
Member? member = await memberRepository.SingleOrDefaultAsync(new GetMemberByIdSpec(req.MemberId), ct);
if (member is null)
{
await Send.NotFoundAsync(ct);
return;
}
if (!member.IsActive)
{
await Send.StringAsync("Le membre est désactivé", 400, cancellation: ct);
@@ -49,7 +49,7 @@ public class CreateReviewEndpoint(
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.NoContentAsync(ct);
}

View File

@@ -17,7 +17,7 @@ public class DeleteReviewEndpoint(ReviewRepository reviewRepository) : Endpoint<
Delete("/reviews/{@Id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(DeleteReviewsRequest req, CancellationToken ct)
{
Review? review = await reviewRepository.SingleOrDefaultAsync(new GetReviewByIdSpec(req.Id), ct);
@@ -27,7 +27,7 @@ public class DeleteReviewEndpoint(ReviewRepository reviewRepository) : Endpoint<
await Send.NotFoundAsync(ct);
return;
}
await reviewRepository.DeleteAsync(review, ct);
await Send.NoContentAsync(ct);
}