source: ChapterX.Application/Admin/Commands/AddHandler.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: 926 bytes
RevLine 
[877c13c]1using ChapterX.Domain.Repositories;
2using MediatR;
3using Microsoft.Extensions.Logging;
4
5namespace ChapterX.Application.Admin.Commands
6{
7 public class AddHandler : IRequestHandler<AddRequest, AddResponse>
8 {
9 private readonly IAdminRepository _adminRepository;
10 private readonly ILogger<AddHandler> _logger;
11
12 public AddHandler(IAdminRepository adminRepository, ILogger<AddHandler> logger)
13 {
14 _adminRepository = adminRepository;
15 _logger = logger;
16 }
17
18 public async Task<AddResponse> Handle(AddRequest request, CancellationToken cancellationToken)
19 {
20 var admin = new Domain.Entities.Admin
21 {
[e882b92]22 Id = request.UserId,
23 AssignedAt = DateTime.UtcNow
[877c13c]24 };
25
26 await _adminRepository.AddAsync(admin, cancellationToken);
27
28 return new AddResponse(admin.Id);
29 }
30 }
31}
Note: See TracBrowser for help on using the repository browser.