public async Task <ActionResult <BasicUserViewModel> > CreateUserAsync(CreateUserCommand createUserCommand) { var user = _mapper.Map <User>(createUserCommand); await _behavior.CreateUserAsync(user); var userViewModel = await _queries.FindByUsernameAsync(user.Username); return(userViewModel); }
public async Task <ActionResult <User> > CreateUserAsync(CreateUserCommand createUserCommand) { var user = _mapper.Map <User>(createUserCommand); await _behavior.CreateUserAsync(user); return(CreatedAtAction( nameof(GetByUsernameAsync), new { username = user.Username }, _mapper.Map <BasicUserViewModel>(user))); }
public async Task <ActionResult <User> > CreateUserAsync(CreateUserCommand createUserCommand) { var existingUser = await _queries.FindByUsernameAsync(createUserCommand.Username); if (existingUser != null) { return(Conflict()); } var user = _mapper.Map <User>(createUserCommand); await _behavior.CreateUserAsync(user); return(user); }