source: ChapterX.Application/Collaboration/Commands/UpdateHandler.cs@ e882b92

main
Last change on this file since e882b92 was e882b92, checked in by kikisrbinoska <srbinoskakristina07@…>, 13 days ago

Added corrected entitef from the ER diagram and changes for the logic to be coresponding to the ddl

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