From 873d0d8df10e1d6403b7a4eac1980f874dfe1d05 Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 31 Jan 2020 22:46:17 +0800 Subject: Make all patch return the new entity. --- Timeline/Controllers/UserController.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Timeline/Controllers/UserController.cs') diff --git a/Timeline/Controllers/UserController.cs b/Timeline/Controllers/UserController.cs index 26e63f63..a3e8d816 100644 --- a/Timeline/Controllers/UserController.cs +++ b/Timeline/Controllers/UserController.cs @@ -55,14 +55,14 @@ namespace Timeline.Controllers } [HttpPatch("users/{username}"), Authorize] - public async Task Patch([FromBody] UserPatchRequest body, [FromRoute][Username] string username) + public async Task> Patch([FromBody] UserPatchRequest body, [FromRoute][Username] string username) { if (this.IsAdministrator()) { try { - await _userService.ModifyUser(username, _mapper.Map(body)); - return Ok(); + var user = await _userService.ModifyUser(username, _mapper.Map(body)); + return Ok(ConvertToUserInfo(user)); } catch (UserNotExistException e) { @@ -92,8 +92,8 @@ namespace Timeline.Controllers return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.CustomMessage_Forbid(UserController_Patch_Forbid_Administrator)); - await _userService.ModifyUser(this.GetUserId(), _mapper.Map(body)); - return Ok(); + var user = await _userService.ModifyUser(this.GetUserId(), _mapper.Map(body)); + return Ok(ConvertToUserInfo(user)); } } -- cgit v1.2.3