source: ChapterX.Application/Notify/Commands/AddHandler.cs@ a8f4a2d

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

Added files

  • Property mode set to 100644
File size: 953 bytes
Line 
1using ChapterX.Domain.Repositories;
2using MediatR;
3using Microsoft.Extensions.Logging;
4
5namespace ChapterX.Application.Notify.Commands
6{
7 public class AddHandler : IRequestHandler<AddRequest, AddResponse>
8 {
9 private readonly INotifyRepository _notifyRepository;
10 private readonly ILogger<AddHandler> _logger;
11
12 public AddHandler(INotifyRepository notifyRepository, ILogger<AddHandler> logger)
13 {
14 _notifyRepository = notifyRepository;
15 _logger = logger;
16 }
17
18 public async Task<AddResponse> Handle(AddRequest request, CancellationToken cancellationToken)
19 {
20 var notify = new Domain.Entities.Notify
21 {
22 UserId = request.UserId,
23 NotificationId = request.NotificationId
24 };
25
26 await _notifyRepository.AddAsync(notify, cancellationToken);
27
28 return new AddResponse(notify.Id);
29 }
30 }
31}
Note: See TracBrowser for help on using the repository browser.