public async Task <ActionResult <BasicUserViewModel> > UpdateUserAsync(string username, UpdateUserCommand updateUserCommand) { var existingUser = await _queries.FindByUsernameAsync(username); if (existingUser == null) { return(NotFound()); } var user = _mapper.Map <User>(existingUser); _mapper.Map(updateUserCommand, user); await _behavior.UpdateUserAsync(user); var userViewModel = await _queries.FindByUsernameAsync(user.Username); return(userViewModel); }
public async Task <IActionResult> UpdateUserAsync(string username, UpdateUserCommand updateUserCommand) { // We are re-using existing Queries // you can also provide methods on the repository // (they could be exposed through a behavior class) // strictly related with transactional logic and // completely specialize your queries with data displaying tasks. var existingUser = await _queries.FindByUsernameAsync(username); if (existingUser == null) { return(NotFound()); } _mapper.Map(updateUserCommand, existingUser); await _behavior.UpdateUserAsync(existingUser); return(NoContent()); }