public async Task <IActionResult> Put(int id, [FromBody] RoleDetailsDto model) { var roleId = id; var roleDetailsDto = model; var role = await Executor.GetQuery <GetRoleByIdQuery>().Process(q => q.ExecuteAsync(roleId)); Mapper.Map(roleDetailsDto, role); try { Executor.CommandChain() .AddCommand <UpdateRoleCommand>(c => c.Execute(role)) .AddCommand <UpdateRoleClaimsCommand>(c => c.Execute(role, roleDetailsDto.Permissions)) .ExecuteAllWithTransaction(); Executor.GetHandler <UpdateRoleRouteStagesHandler>() .Process <int>(h => h.Execute(roleId, roleDetailsDto.RoleStages)); } catch (Exception e) { throw new DatabaseException(e.InnerException?.Message ?? e.Message); } return(NoContent()); }
public async Task <IActionResult> Put(int id, [FromBody] RoleDetailsDto model) { await _mediator.Send(new Update.Command { RoleDetailsDto = model, RoleId = id }); return(NoContent()); }
public async Task ExecuteAsync(RoleDetailsDto roleDetailsDto) { var role = _mapper.Map <ApplicationRole>(roleDetailsDto); NormalizeRoleCode(role); try { var resultOfRoleCreated = await _roleManager.CreateAsync(role); if (resultOfRoleCreated.Succeeded == false) { throw new ValidationException(string.Join(", ", resultOfRoleCreated.Errors.Select(x => x.Description))); } await _roleClaimsUpdater.UpdateAsync(role, roleDetailsDto.Permissions); await _roleRouteStagesUpdater.UpdateAsync(role.Id, roleDetailsDto.RoleStages); } catch (Exception e) { throw new DatabaseException(e.InnerException?.Message ?? e.Message); } }
public async Task <IActionResult> Post([FromBody] RoleDetailsDto model) { await _mediator.Send(new Create.Command(model)); return(NoContent()); }
public async Task <IActionResult> Post([FromBody] RoleDetailsDto model) { await Executor.GetHandler <CreateRoleHandler>().Process(h => h.ExecuteAsync(model)); return(NoContent()); }
private void MapFromDto(Domain.Entities.Security.ApplicationRole role, RoleDetailsDto roleDto) { _mapper.Map(roleDto, role); }
private Domain.Entities.Security.ApplicationRole MapFromDto(RoleDetailsDto roleDto) { return(_mapper.Map <Domain.Entities.Security.ApplicationRole>(roleDto)); }
public Command(RoleDetailsDto roleDetailsDto) { RoleDetailsDto = roleDetailsDto; }