From 83cee23d8091c99bddbecdee2b9003794480b079 Mon Sep 17 00:00:00 2001 From: 杨宇千 Date: Mon, 4 Nov 2019 21:02:12 +0800 Subject: Complete designing timeline service though there may be many bugs in the design. --- Timeline/Services/TimelineService.cs | 63 +++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 22 deletions(-) (limited to 'Timeline/Services/TimelineService.cs') diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs index cf130a70..9d309e7e 100644 --- a/Timeline/Services/TimelineService.cs +++ b/Timeline/Services/TimelineService.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Threading.Tasks; using Timeline.Entities; @@ -8,25 +7,6 @@ using Timeline.Models; namespace Timeline.Services { - - [Serializable] - public class TimelineMemberOperationException : Exception - { - public TimelineMemberOperationException() : base(Resources.Services.Exception.TimelineMemberOperationException) { } - public TimelineMemberOperationException(string message) : base(message) { } - public TimelineMemberOperationException(string message, Exception inner) : base(message, inner) { } - protected TimelineMemberOperationException( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) : base(info, context) { } - - public TimelineMemberOperationException(int index, Exception inner) : base(MakeIndexMessage(index), inner) { Index = index; } - - private static string MakeIndexMessage(int index) => string.Format(CultureInfo.CurrentCulture, - Resources.Services.Exception.TimelineMemberOperationExceptionIndex, index); - - public int? Index { get; set; } - } - /// /// This define the common interface of both personal timeline /// and normal timeline. @@ -141,8 +121,12 @@ namespace Timeline.Services /// For personal timeline, it means the user of that username does not exist /// and the inner exception should be a . /// - /// - /// TODO! complete this documents. + /// + /// Thrown when an exception occurs on users in the list. + /// The inner exception is + /// when one of the username is not valid. + /// The inner exception is + /// when one of the user does not exist. /// Task AddMember(string name, IList usernames); @@ -164,6 +148,13 @@ namespace Timeline.Services /// For personal timeline, it means the user of that username does not exist /// and the inner exception should be a . /// + /// + /// Thrown when an exception occurs on the user list. + /// The inner exception is + /// when one of the username is invalid. + /// The inner exception is + /// when one of the user is not a member of the timeline. + /// Task RemoveMember(string name, IList usernames); } @@ -177,6 +168,13 @@ namespace Timeline.Services /// /// The name of the timeline. /// The timeline info. + /// Thrown when is null. + /// + /// Thrown when timeline name is invalid. Currently it means it is an empty string. + /// + /// + /// Thrown when timeline with the name does not exist. + /// Task GetTimeline(string name); /// @@ -184,6 +182,18 @@ namespace Timeline.Services /// /// The name of the timeline. /// The owner of the timeline. + /// Thrown when or is null. + /// + /// Thrown when timeline name is invalid. Currently it means it is an empty string. + /// + /// + /// Thrown when the timeline already exists. + /// + /// + /// Thrown when the username of the owner is not valid. + /// + /// + /// Thrown when the owner user does not exist. Task CreateTimeline(string name, string owner); } @@ -194,6 +204,15 @@ namespace Timeline.Services /// /// The username of the owner of the personal timeline. /// The timeline info. + /// + /// Thrown when is null. + /// + /// + /// Thrown when is of bad format. Inner exception MUST be . + /// + /// + /// Thrown when the user does not exist. Inner exception MUST be . + /// Task GetTimeline(string username); } } -- cgit v1.2.3