From 1a44a615ad79054218d493f8bc4bf8563201002b Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 7 Jan 2021 20:48:47 +0800 Subject: feat: Add check existence feature to bookmark and highlight service. --- BackEnd/Timeline/Services/HighlightTimelineService.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'BackEnd/Timeline/Services/HighlightTimelineService.cs') diff --git a/BackEnd/Timeline/Services/HighlightTimelineService.cs b/BackEnd/Timeline/Services/HighlightTimelineService.cs index bf0aac91..557478c7 100644 --- a/BackEnd/Timeline/Services/HighlightTimelineService.cs +++ b/BackEnd/Timeline/Services/HighlightTimelineService.cs @@ -31,6 +31,15 @@ namespace Timeline.Services /// Id list of all highlight timelines. Task> GetHighlightTimelines(); + /// + /// Check if a timeline is highlight timeline. + /// + /// Timeline id. + /// If true it will throw if timeline does not exist. + /// True if timeline is highlight. Otherwise false. + /// Thrown when timeline does not exist and is true. + Task IsHighlightTimeline(long timelineId, bool checkTimelineExistence = true); + /// /// Add a timeline to highlight list. /// @@ -172,5 +181,13 @@ namespace Timeline.Services await transaction.CommitAsync(); } + + public async Task IsHighlightTimeline(long timelineId, bool checkTimelineExistence = true) + { + if (checkTimelineExistence && !await _timelineService.CheckExistence(timelineId)) + throw new TimelineNotExistException(timelineId); + + return await _database.HighlightTimelines.AnyAsync(t => t.TimelineId == timelineId); + } } } -- cgit v1.2.3