diff options
author | crupest <crupest@outlook.com> | 2021-01-07 22:13:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-07 22:13:24 +0800 |
commit | 34b2304997bfac1e186dad660ec62d8d87fec75f (patch) | |
tree | 2ca5678d575eae81f71220896a9862468c93fcc3 /BackEnd/Timeline/Services/HighlightTimelineService.cs | |
parent | e701f8bab033dd364673215e66d58a1cb9fea339 (diff) | |
parent | 04186d5f1091266b85758d4b4255c6a7c1b498f6 (diff) | |
download | timeline-34b2304997bfac1e186dad660ec62d8d87fec75f.tar.gz timeline-34b2304997bfac1e186dad660ec62d8d87fec75f.tar.bz2 timeline-34b2304997bfac1e186dad660ec62d8d87fec75f.zip |
Merge pull request #204 from crupest/back-dev
Timeline info includes highlight and bookmark info.
Diffstat (limited to 'BackEnd/Timeline/Services/HighlightTimelineService.cs')
-rw-r--r-- | BackEnd/Timeline/Services/HighlightTimelineService.cs | 17 |
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);
+ }
}
}
|