aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Services/HighlightTimelineService.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-01-07 20:48:47 +0800
committercrupest <crupest@outlook.com>2021-01-07 20:48:47 +0800
commit11fd53b9de139a4ed089fcd16085afb267cc435f (patch)
treec2178b15b08246c1e65b3d3446e60acfd56dffa9 /BackEnd/Timeline/Services/HighlightTimelineService.cs
parent191b92a161c4fdad532dbf471f5c33f8f4a97a23 (diff)
downloadtimeline-11fd53b9de139a4ed089fcd16085afb267cc435f.tar.gz
timeline-11fd53b9de139a4ed089fcd16085afb267cc435f.tar.bz2
timeline-11fd53b9de139a4ed089fcd16085afb267cc435f.zip
feat: Add check existence feature to bookmark and highlight service.
Diffstat (limited to 'BackEnd/Timeline/Services/HighlightTimelineService.cs')
-rw-r--r--BackEnd/Timeline/Services/HighlightTimelineService.cs17
1 files changed, 17 insertions, 0 deletions
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
@@ -32,6 +32,15 @@ namespace Timeline.Services
Task<List<long>> GetHighlightTimelines();
/// <summary>
+ /// Check if a timeline is highlight timeline.
+ /// </summary>
+ /// <param name="timelineId">Timeline id.</param>
+ /// <param name="checkTimelineExistence">If true it will throw if timeline does not exist.</param>
+ /// <returns>True if timeline is highlight. Otherwise false.</returns>
+ /// <exception cref="TimelineNotExistException">Thrown when timeline does not exist and <paramref name="checkTimelineExistence"/> is true.</exception>
+ Task<bool> IsHighlightTimeline(long timelineId, bool checkTimelineExistence = true);
+
+ /// <summary>
/// Add a timeline to highlight list.
/// </summary>
/// <param name="timelineId">The timeline id.</param>
@@ -172,5 +181,13 @@ namespace Timeline.Services
await transaction.CommitAsync();
}
+
+ public async Task<bool> 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);
+ }
}
}