diff options
author | crupest <crupest@outlook.com> | 2020-01-31 22:46:17 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-01-31 22:46:17 +0800 |
commit | 69a5cc2a6f3282de4859d7c083bd67dfa17226fb (patch) | |
tree | f969a960472bbf828e5d639a8deef65341b52a6a /Timeline/Controllers/UserController.cs | |
parent | 3749a642306b19c84f324b0e94c4d62d8ec60332 (diff) | |
download | timeline-69a5cc2a6f3282de4859d7c083bd67dfa17226fb.tar.gz timeline-69a5cc2a6f3282de4859d7c083bd67dfa17226fb.tar.bz2 timeline-69a5cc2a6f3282de4859d7c083bd67dfa17226fb.zip |
Make all patch return the new entity.
Diffstat (limited to 'Timeline/Controllers/UserController.cs')
-rw-r--r-- | Timeline/Controllers/UserController.cs | 10 |
1 files changed, 5 insertions, 5 deletions
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<ActionResult> Patch([FromBody] UserPatchRequest body, [FromRoute][Username] string username)
+ public async Task<ActionResult<UserInfo>> Patch([FromBody] UserPatchRequest body, [FromRoute][Username] string username)
{
if (this.IsAdministrator())
{
try
{
- await _userService.ModifyUser(username, _mapper.Map<User>(body));
- return Ok();
+ var user = await _userService.ModifyUser(username, _mapper.Map<User>(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<User>(body));
- return Ok();
+ var user = await _userService.ModifyUser(this.GetUserId(), _mapper.Map<User>(body));
+ return Ok(ConvertToUserInfo(user));
}
}
|