public ActionResult UpdateUser([FromRoute] string id, UserCreateDto userUpdateDto) { var modelFromRepo = _repository.GetUserById(id); if (modelFromRepo == null) { return(NotFound()); } _mapper.Map(userUpdateDto, modelFromRepo); _repository.UpdateUser(modelFromRepo); _repository.SaveChanges(); return(NoContent()); }
public async Task <ActionResult> UpdateUser(int id, UserUpdateDto userUpdateDto) { Response.Headers.Add("Access-Control-Allow-Origin", "*"); User userToUpdate = await _repository.GetUserById(id); if (userToUpdate == null) { return(NotFound()); } _mapper.Map(userUpdateDto, userToUpdate); if (!await _repository.UpdateUser(userToUpdate)) { return(StatusCode(StatusCodes.Status502BadGateway)); } return(NoContent()); }