From e110f4a41bd711192af28874f71f031a130f0b84 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 5 May 2021 16:18:33 +0800 Subject: refactor: ... --- BackEnd/Timeline/Services/Api/BookmarkTimelineService.cs | 5 ++++- BackEnd/Timeline/Services/Api/HighlightTimelineService.cs | 5 ++++- BackEnd/Timeline/Services/Api/IBookmarkTimelineService.cs | 2 +- .../Timeline/Services/Api/IHighlightTimelineService.cs | 2 +- BackEnd/Timeline/Services/Api/InvalidBookmarkException.cs | 15 --------------- .../Services/Api/InvalidHighlightTimelineException.cs | 15 --------------- 6 files changed, 10 insertions(+), 34 deletions(-) delete mode 100644 BackEnd/Timeline/Services/Api/InvalidBookmarkException.cs delete mode 100644 BackEnd/Timeline/Services/Api/InvalidHighlightTimelineException.cs (limited to 'BackEnd/Timeline/Services/Api') diff --git a/BackEnd/Timeline/Services/Api/BookmarkTimelineService.cs b/BackEnd/Timeline/Services/Api/BookmarkTimelineService.cs index de70a9db..9d6ec93f 100644 --- a/BackEnd/Timeline/Services/Api/BookmarkTimelineService.cs +++ b/BackEnd/Timeline/Services/Api/BookmarkTimelineService.cs @@ -68,7 +68,10 @@ namespace Timeline.Services.Api var entity = await _database.BookmarkTimelines.SingleOrDefaultAsync(t => t.TimelineId == timelineId && t.UserId == userId); - if (entity == null) throw new InvalidBookmarkException("You can't move a non-bookmark timeline."); + if (entity is null) + { + throw new EntityNotExistException(EntityTypes.BookmarkTimeline); + } var oldPosition = entity.Rank; diff --git a/BackEnd/Timeline/Services/Api/HighlightTimelineService.cs b/BackEnd/Timeline/Services/Api/HighlightTimelineService.cs index d4367e57..eb606ae6 100644 --- a/BackEnd/Timeline/Services/Api/HighlightTimelineService.cs +++ b/BackEnd/Timeline/Services/Api/HighlightTimelineService.cs @@ -81,7 +81,10 @@ namespace Timeline.Services.Api var entity = await _database.HighlightTimelines.SingleOrDefaultAsync(t => t.TimelineId == timelineId); - if (entity == null) throw new InvalidHighlightTimelineException("You can't move a non-highlight timeline."); + if (entity is null) + { + throw new EntityNotExistException(EntityTypes.HighlightTimeline); + } var oldPosition = entity.Order; diff --git a/BackEnd/Timeline/Services/Api/IBookmarkTimelineService.cs b/BackEnd/Timeline/Services/Api/IBookmarkTimelineService.cs index c3cda450..468a885b 100644 --- a/BackEnd/Timeline/Services/Api/IBookmarkTimelineService.cs +++ b/BackEnd/Timeline/Services/Api/IBookmarkTimelineService.cs @@ -56,7 +56,7 @@ namespace Timeline.Services.Api /// New position. Starts at 1. /// Thrown when user does not exist. /// Thrown when timeline does not exist. - /// Thrown when the timeline is not a bookmark. + /// Thrown when the timeline is not a bookmark. Task MoveBookmarkAsync(long userId, long timelineId, long newPosition); } } diff --git a/BackEnd/Timeline/Services/Api/IHighlightTimelineService.cs b/BackEnd/Timeline/Services/Api/IHighlightTimelineService.cs index 56a0fb35..0ca6759c 100644 --- a/BackEnd/Timeline/Services/Api/IHighlightTimelineService.cs +++ b/BackEnd/Timeline/Services/Api/IHighlightTimelineService.cs @@ -49,7 +49,7 @@ namespace Timeline.Services.Api /// The timeline name. /// The new position. Starts at 1. /// Thrown when timeline with given id does not exist. - /// Thrown when given timeline is not a highlight timeline. + /// Thrown when given timeline is not a highlight timeline. /// /// If is smaller than 1. Then move the timeline to head. /// If is bigger than total count. Then move the timeline to tail. diff --git a/BackEnd/Timeline/Services/Api/InvalidBookmarkException.cs b/BackEnd/Timeline/Services/Api/InvalidBookmarkException.cs deleted file mode 100644 index 39572b38..00000000 --- a/BackEnd/Timeline/Services/Api/InvalidBookmarkException.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace Timeline.Services.Api -{ - [Serializable] - public class InvalidBookmarkException : Exception - { - public InvalidBookmarkException() { } - public InvalidBookmarkException(string message) : base(message) { } - public InvalidBookmarkException(string message, Exception inner) : base(message, inner) { } - protected InvalidBookmarkException( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) : base(info, context) { } - } -} diff --git a/BackEnd/Timeline/Services/Api/InvalidHighlightTimelineException.cs b/BackEnd/Timeline/Services/Api/InvalidHighlightTimelineException.cs deleted file mode 100644 index 13b04a6b..00000000 --- a/BackEnd/Timeline/Services/Api/InvalidHighlightTimelineException.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace Timeline.Services.Api -{ - [Serializable] - public class InvalidHighlightTimelineException : Exception - { - public InvalidHighlightTimelineException() { } - public InvalidHighlightTimelineException(string message) : base(message) { } - public InvalidHighlightTimelineException(string message, Exception inner) : base(message, inner) { } - protected InvalidHighlightTimelineException( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) : base(info, context) { } - } -} -- cgit v1.2.3