Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425
  1. using Diligent.WebAPI.Data.Entities;
  2. using Diligent.WebAPI.Host.Mediator.Authentication.Commands;
  3. using MediatR;
  4. using Microsoft.AspNetCore.Identity;
  5. using System.Diagnostics.CodeAnalysis;
  6. namespace Diligent.WebAPI.Host.Mediator.Authentication.Handlers
  7. {
  8. [ExcludeFromCodeCoverage]
  9. public class AddRoleHandler : IRequestHandler<AddRoleCommand, Unit>
  10. {
  11. private readonly RoleManager<Roles> _roleManager;
  12. public AddRoleHandler(RoleManager<Roles> roleManager)
  13. {
  14. _roleManager = roleManager;
  15. }
  16. public async Task<Unit> Handle(AddRoleCommand request, CancellationToken cancellationToken)
  17. {
  18. await _roleManager.CreateAsync(new Roles() { Name = request.NameOfRole });
  19. return new Unit();
  20. }
  21. }
  22. }