source: ChapterX.Application/Collaboration/Commands/DeleteHandler.cs@ e294f7d

main
Last change on this file since e294f7d was 877c13c, checked in by kikisrbinoska <srbinoskakristina07@…>, 4 months ago

Added files

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[877c13c]1using ChapterX.Domain.Repositories;
2using MediatR;
3using Microsoft.Extensions.Logging;
4
5namespace ChapterX.Application.Collaboration.Commands
6{
7 public class DeleteHandler : IRequestHandler<DeleteRequest, DeleteResponse>
8 {
9 private readonly ICollaborationRepository _collaborationRepository;
10 private readonly ILogger<DeleteHandler> _logger;
11
12 public DeleteHandler(ICollaborationRepository collaborationRepository, ILogger<DeleteHandler> logger)
13 {
14 _collaborationRepository = collaborationRepository;
15 _logger = logger;
16 }
17
18 public async Task<DeleteResponse> Handle(DeleteRequest request, CancellationToken cancellationToken)
19 {
20 var collaboration = await _collaborationRepository.GetByIdAsync(request.Id, cancellationToken);
21 if (collaboration is null)
22 return new DeleteResponse(false);
23
24 await _collaborationRepository.DeleteAsync(collaboration, cancellationToken);
25
26 return new DeleteResponse(true);
27 }
28 }
29}
Note: See TracBrowser for help on using the repository browser.