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 { private readonly RoleManager _roleManager; public AddRoleHandler(RoleManager roleManager) { _roleManager = roleManager; } public async Task Handle(AddRoleCommand request, CancellationToken cancellationToken) { await _roleManager.CreateAsync(new Roles() { Name = request.NameOfRole }); return new Unit(); } } }