aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers/UserAvatarController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-04-30 16:52:55 +0800
committercrupest <crupest@outlook.com>2021-04-30 16:52:55 +0800
commita672e10faad434899d81ef9d0d0d5adbbc7841da (patch)
tree33c18e4bdad7384c748cf08be1f0569f9a8af619 /BackEnd/Timeline/Controllers/UserAvatarController.cs
parentb87abbb8ed0aa86a808b2f97e4d22b0ee1addd9f (diff)
downloadtimeline-a672e10faad434899d81ef9d0d0d5adbbc7841da.tar.gz
timeline-a672e10faad434899d81ef9d0d0d5adbbc7841da.tar.bz2
timeline-a672e10faad434899d81ef9d0d0d5adbbc7841da.zip
refactor: ...
Diffstat (limited to 'BackEnd/Timeline/Controllers/UserAvatarController.cs')
-rw-r--r--BackEnd/Timeline/Controllers/UserAvatarController.cs32
1 files changed, 4 insertions, 28 deletions
diff --git a/BackEnd/Timeline/Controllers/UserAvatarController.cs b/BackEnd/Timeline/Controllers/UserAvatarController.cs
index b1129329..5d9becaa 100644
--- a/BackEnd/Timeline/Controllers/UserAvatarController.cs
+++ b/BackEnd/Timeline/Controllers/UserAvatarController.cs
@@ -44,16 +44,8 @@ namespace Timeline.Controllers
public async Task<IActionResult> Get([FromRoute][Username] string username, [FromHeader(Name = "If-None-Match")] string? ifNoneMatch)
{
_ = ifNoneMatch;
- try
- {
- long userId = await _userService.GetUserIdByUsernameAsync(username);
- return await DataCacheHelper.GenerateActionResult(this, () => _service.GetAvatarDigestAsync(userId), () => _service.GetAvatarAsync(userId));
- }
- catch (UserNotExistException)
- {
- return NotFound(ErrorResponse.UserCommon.NotExist());
- }
-
+ long userId = await _userService.GetUserIdByUsernameAsync(username);
+ return await DataCacheHelper.GenerateActionResult(this, () => _service.GetAvatarDigestAsync(userId), () => _service.GetAvatarAsync(userId));
}
/// <summary>
@@ -76,15 +68,7 @@ namespace Timeline.Controllers
return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
}
- long id;
- try
- {
- id = await _userService.GetUserIdByUsernameAsync(username);
- }
- catch (UserNotExistException)
- {
- return BadRequest(ErrorResponse.UserCommon.NotExist());
- }
+ long id = await _userService.GetUserIdByUsernameAsync(username);
try
{
@@ -127,15 +111,7 @@ namespace Timeline.Controllers
return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
}
- long id;
- try
- {
- id = await _userService.GetUserIdByUsernameAsync(username);
- }
- catch (UserNotExistException)
- {
- return BadRequest(ErrorResponse.UserCommon.NotExist());
- }
+ long id = await _userService.GetUserIdByUsernameAsync(username);
await _service.DeleteAvatarAsync(id);
return Ok();