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/PersonalTimelineController.cs | 5 +++-- Timeline/Controllers/UserController.cs | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'Timeline/Controllers') diff --git a/Timeline/Controllers/PersonalTimelineController.cs b/Timeline/Controllers/PersonalTimelineController.cs index 27618c41..11353bb5 100644 --- a/Timeline/Controllers/PersonalTimelineController.cs +++ b/Timeline/Controllers/PersonalTimelineController.cs @@ -77,14 +77,15 @@ namespace Timeline.Controllers [HttpPatch("users/{username}/timeline")] [Authorize] - public async Task TimelinePatch([FromRoute][Username] string username, [FromBody] TimelinePatchRequest body) + public async Task> TimelinePatch([FromRoute][Username] string username, [FromBody] TimelinePatchRequest body) { if (!this.IsAdministrator() && !(User.Identity.Name == username)) { return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid()); } await _service.ChangeProperty(username, body); - return Ok(); + var timeline = await _service.GetTimeline(username); + return Ok(timeline); } [HttpPut("users/{username}/timeline/members/{member}")] 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