diff options
author | crupest <crupest@outlook.com> | 2020-12-18 18:01:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-12-18 18:01:25 +0800 |
commit | 26b94a034c5a91b3a903b91c3c61acbbf78db401 (patch) | |
tree | 82cf6558144a345a50a9b7f978a1f5c6460e141c | |
parent | 10956dbadfba39f38fcffcd5c144e6f0302ac5ee (diff) | |
download | timeline-26b94a034c5a91b3a903b91c3c61acbbf78db401.tar.gz timeline-26b94a034c5a91b3a903b91c3c61acbbf78db401.tar.bz2 timeline-26b94a034c5a91b3a903b91c3c61acbbf78db401.zip |
feat: Add bookmark timeline service interface.
-rw-r--r-- | BackEnd/Timeline/Services/BookmarkTimelineService.cs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/BackEnd/Timeline/Services/BookmarkTimelineService.cs b/BackEnd/Timeline/Services/BookmarkTimelineService.cs new file mode 100644 index 00000000..7eb691b7 --- /dev/null +++ b/BackEnd/Timeline/Services/BookmarkTimelineService.cs @@ -0,0 +1,74 @@ +using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Timeline.Models;
+using Timeline.Services.Exceptions;
+
+namespace Timeline.Services
+{
+
+ [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) { }
+ }
+
+ /// <summary>
+ /// Service interface that manages timeline bookmarks.
+ /// </summary>
+ public interface IBookmarkTimelineService
+ {
+ /// <summary>
+ /// Get bookmarks of a user.
+ /// </summary>
+ /// <param name="userId">User id of bookmark owner.</param>
+ /// <returns>Bookmarks in order.</returns>
+ /// <exception cref="UserNotExistException">Thrown when user does not exist.</exception>
+ Task<List<TimelineInfo>> GetBookmarks(long userId);
+
+ /// <summary>
+ /// Add a bookmark to tail to a user.
+ /// </summary>
+ /// <param name="userId">User id of bookmark owner.</param>
+ /// <param name="timelineName">Timeline name.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="timelineName"/> is null.</exception>
+ /// <exception cref="ArgumentException">Thrown when <paramref name="timelineName"/> is not a valid name.</exception>
+ /// <exception cref="UserNotExistException">Thrown when user does not exist.</exception>
+ /// <exception cref="TimelineNotExistException">Thrown when timeline does not exist.</exception>
+ Task AddBookmark(long userId, string timelineName);
+
+ /// <summary>
+ /// Remove a bookmark from a user.
+ /// </summary>
+ /// <param name="userId">User id of bookmark owner.</param>
+ /// <param name="timelineName">Timeline name.</param>
+ /// <returns>True if deletion is performed. False if bookmark does not exist.</returns>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="timelineName"/> is null.</exception>
+ /// <exception cref="ArgumentException">Thrown when <paramref name="timelineName"/> is not a valid name.</exception>
+ /// <exception cref="UserNotExistException">Thrown when user does not exist.</exception>
+ /// <exception cref="TimelineNotExistException">Thrown when timeline does not exist.</exception>
+ Task<bool> RemoveBookmark(long userId, string timelineName);
+
+ /// <summary>
+ /// Move bookmark to a new position.
+ /// </summary>
+ /// <param name="userId">User id of bookmark owner.</param>
+ /// <param name="timelineName">Timeline name.</param>
+ /// <param name="position">New position. Starts at 1.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="timelineName"/> is null.</exception>
+ /// <exception cref="ArgumentException">Thrown when <paramref name="timelineName"/> is not a valid name.</exception>
+ /// <exception cref="UserNotExistException">Thrown when user does not exist.</exception>
+ /// <exception cref="TimelineNotExistException">Thrown when timeline does not exist.</exception>
+ /// <exception cref="InvalidBookmarkException">Thrown when the timeline is not a bookmark.</exception>
+ Task MoveBookmark(long userId, string timelineName, long position);
+ }
+
+ public class BookmarkTimelineService
+ {
+ }
+}
|