public async Task <IActionResult> Post([FromBody] CreateUserApiInput input) { var createUserResult = await _mediator.Send(_mapper.Map <CreateUserCommand>(input)); if (createUserResult.IsFailure()) { return(createUserResult.ToActionResult()); } var createdUser = await _userManager.FindByIdAsync(createUserResult.Value); return(Json(_mapper.Map <UserDto>(createdUser))); }
public async Task <IActionResult> Create([BindRequired, FromBody] CreateUserApiInput input) { var result = await _mediator.Send(new CreateUserCommand { UserName = input.UserName, Password = input.Password, Permissions = input.Permissions?.GroupBy(it => it.Resource).Select(it => new UserPermission { Resource = it.Key, AccessRight = it.Aggregate(it.First().AccessRight, (acc, cur) => acc | cur.AccessRight) }).ToArray() }).ConfigureAwait(false); return(new ExecutionResult <UserReadModel> { Value = result.Value == null ? null : new UserReadModel(result.Value), ResultType = result.ResultType, Message = result.Message }.ToActionResult()); }