| 123456789101112131415161718192021222324 |
- using Diligent.WebAPI.Data.Entities;
- using Diligent.WebAPI.Host.Mediator.Authentication.Commands;
- using MediatR;
- using Microsoft.AspNetCore.Identity;
- using System.Web.Http.ModelBinding;
-
- namespace Diligent.WebAPI.Host.Mediator.Authentication.Handlers
- {
- public class AddRoleHandler : IRequestHandler<AddRoleCommand, Unit>
- {
- private readonly RoleManager<Roles> _roleManager;
-
- public AddRoleHandler(RoleManager<Roles> roleManager)
- {
- _roleManager = roleManager;
- }
- public async Task<Unit> Handle(AddRoleCommand request, CancellationToken cancellationToken)
- {
- await _roleManager.CreateAsync(new Roles() { Name = request.NameOfRole });
-
- return new Unit();
- }
- }
- }
|