Cleaned code
This commit is contained in:
@@ -17,7 +17,7 @@ public class DeleteAuthorEndpoint(AuthorRepository authorRepository) : Endpoint<
|
||||
Delete("/authors/{@Id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
|
||||
public override async Task HandleAsync(DeleteAuthorRequest req, CancellationToken ct)
|
||||
{
|
||||
Author? author = await authorRepository.SingleOrDefaultAsync(new GetAuthorByIdSpec(req.Id), ct);
|
||||
@@ -30,11 +30,12 @@ public class DeleteAuthorEndpoint(AuthorRepository authorRepository) : Endpoint<
|
||||
|
||||
if (author.Books?.Count > 0)
|
||||
{
|
||||
await Send.StringAsync("L'auteur possède encore des livres",409, cancellation: ct);
|
||||
await Send.StringAsync("L'auteur possède encore des livres", 409, cancellation: ct);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
await authorRepository.DeleteAsync(author, ct);
|
||||
await Send.NoContentAsync(ct);;
|
||||
await Send.NoContentAsync(ct);
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ public class GetAuthorsEndpoint(AuthorRepository authorRepository) : EndpointWit
|
||||
Get("/authors/");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
await Send.OkAsync(await authorRepository.ProjectToListAsync<GetAuthorDto>(ct), ct);
|
||||
|
||||
@@ -22,7 +22,7 @@ public class UpdateAuthorEndpoint(AuthorRepository authorRepository, AutoMapper.
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mapper.Map(req, author);
|
||||
await authorRepository.SaveChangesAsync(ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
|
||||
Reference in New Issue
Block a user