From 88002173a1155883d1fb46683a9a7ad1f521eb56 Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 30 Apr 2021 16:52:55 +0800 Subject: refactor: ... --- .../Controllers/HighlightTimelineController.cs | 30 +++++----------------- 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'BackEnd/Timeline/Controllers/HighlightTimelineController.cs') diff --git a/BackEnd/Timeline/Controllers/HighlightTimelineController.cs b/BackEnd/Timeline/Controllers/HighlightTimelineController.cs index ffaa50c1..e73bc7a9 100644 --- a/BackEnd/Timeline/Controllers/HighlightTimelineController.cs +++ b/BackEnd/Timeline/Controllers/HighlightTimelineController.cs @@ -60,16 +60,9 @@ namespace Timeline.Controllers [ProducesResponseType(403)] public async Task> Put([GeneralTimelineName] string timeline) { - try - { - var timelineId = await _timelineService.GetTimelineIdByNameAsync(timeline); - var create = await _service.AddHighlightTimelineAsync(timelineId, this.GetUserId()); - return CommonPutResponse.Create(create); - } - catch (TimelineNotExistException) - { - return BadRequest(ErrorResponse.TimelineController.NotExist()); - } + var timelineId = await _timelineService.GetTimelineIdByNameAsync(timeline); + var create = await _service.AddHighlightTimelineAsync(timelineId, this.GetUserId()); + return CommonPutResponse.Create(create); } /// @@ -84,16 +77,9 @@ namespace Timeline.Controllers [ProducesResponseType(403)] public async Task> Delete([GeneralTimelineName] string timeline) { - try - { - var timelineId = await _timelineService.GetTimelineIdByNameAsync(timeline); - var delete = await _service.RemoveHighlightTimelineAsync(timelineId, this.GetUserId()); - return CommonDeleteResponse.Create(delete); - } - catch (TimelineNotExistException) - { - return BadRequest(ErrorResponse.TimelineController.NotExist()); - } + var timelineId = await _timelineService.GetTimelineIdByNameAsync(timeline); + var delete = await _service.RemoveHighlightTimelineAsync(timelineId, this.GetUserId()); + return CommonDeleteResponse.Create(delete); } /// @@ -113,10 +99,6 @@ namespace Timeline.Controllers await _service.MoveHighlightTimelineAsync(timelineId, body.NewPosition!.Value); return Ok(); } - catch (TimelineNotExistException) - { - return BadRequest(ErrorResponse.TimelineController.NotExist()); - } catch (InvalidHighlightTimelineException) { return BadRequest(new CommonResponse(ErrorCodes.HighlightTimelineController.NonHighlight, "Can't move a non-highlight timeline.")); -- cgit v1.2.3