public async Task <IActionResult> Update(string id, [FromBody] View.UserPatchInfo userToUpdate) { var user = UserConverter.ConvertPatchInfo(userToUpdate); var guidId = Guid.Parse(id); Guid.TryParse(HttpContext.User.Identity.Name, out var userId); if (userId != guidId) { return(BadRequest(new { message = "Запрещено для этого пользователя" })); } user.Id = guidId; try { await userService.UpdateAsync(user, userToUpdate.Password); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public IActionResult Update(string id, [FromBody] View.UserPatchInfo userToUpdate) { var user = UserConverter.ConvertPatchInfo(userToUpdate); var guidId = Guid.Parse(id); user.Id = guidId; try { userService.Update(user, userToUpdate.Password); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }