using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Timeline.Entities;
using Timeline.Models;
namespace Timeline.Services
{
///
/// This define the common interface of both personal timeline
/// and normal timeline.
///
///
/// The "name" parameter in method means name of timeline in
/// while username of the owner
/// of the personal timeline in .
///
public interface IBaseTimelineService
{
///
/// Get all the posts in the timeline.
///
/// Username or the timeline name. See remarks of .
/// A list of all posts.
/// Thrown when is null.
///
/// Thrown when timeline name is of bad format.
/// For normal timeline, it means name is an empty string.
/// For personal timeline, it means the username is of bad format,
/// the inner exception should be a .
///
///
/// Thrown when timeline does not exist.
/// For normal timeline, it means the name does not exist.
/// For personal timeline, it means the user of that username does not exist
/// and the inner exception should be a .
///
Task> GetPosts(string name);
///
/// Create a new post in timeline.
///
/// Username or the timeline name. See remarks of .
/// The author's username.
/// The content.
/// The time of the post. If null, then use current time.
///
/// Thrown when or or is null.
///
/// Thrown when timeline name is of bad format.
/// For normal timeline, it means name is an empty string.
/// For personal timeline, it means the username is of bad format,
/// the inner exception should be a .
///
///
/// Thrown when timeline does not exist.
/// For normal timeline, it means the name does not exist.
/// For personal timeline, it means the user of that username does not exist
/// and the inner exception should be a .
///
/// Thrown if is of bad format.
/// Thrown if does not exist.
Task Post(string name, string author, string content, DateTime? time);
///
/// Set the visibility permission of a timeline.
///
/// Username or the timeline name. See remarks of .
/// The new visibility.
/// Thrown when is null.
///
/// Thrown when timeline name is of bad format.
/// For normal timeline, it means name is an empty string.
/// For personal timeline, it means the username is of bad format,
/// the inner exception should be a .
///
///
/// Thrown when timeline does not exist.
/// For normal timeline, it means the name does not exist.
/// For personal timeline, it means the user of that username does not exist
/// and the inner exception should be a .
///
Task SetVisibility(string name, TimelineVisibility visibility);
///
/// Set the description of a timeline.
///
/// Username or the timeline name. See remarks of .
/// The new description.
/// Thrown when or is null.
///
/// Thrown when timeline name is of bad format.
/// For normal timeline, it means name is an empty string.
/// For personal timeline, it means the username is of bad format,
/// the inner exception should be a .
///
///
/// Thrown when timeline does not exist.
/// For normal timeline, it means the name does not exist.
/// For personal timeline, it means the user of that username does not exist
/// and the inner exception should be a .
///
Task SetDescription(string name, string description);
///
/// Add members to a timeline.
///
/// Username or the timeline name. See remarks of .
/// A list of new members' usernames
/// Thrown when or is null.
///
/// Thrown when timeline name is of bad format.
/// For normal timeline, it means name is an empty string.
/// For personal timeline, it means the username is of bad format,
/// the inner exception should be a .
///
///
/// Thrown when timeline does not exist.
/// For normal timeline, it means the name does not exist.
/// 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 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);
///
/// Remove members to a timeline.
///
/// Username or the timeline name. See remarks of .
/// A list of members' usernames
/// Thrown when is null.
///
/// Thrown when timeline name is of bad format.
/// For normal timeline, it means name is an empty string.
/// For personal timeline, it means the username is of bad format,
/// the inner exception should be a .
///
///
/// Thrown when timeline does not exist.
/// For normal timeline, it means the name does not exist.
/// 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);
}
///
/// Service for normal timeline.
///
public interface ITimelineService : IBaseTimelineService
{
///
/// Get the timeline info.
///
/// 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);
///
/// Create a timeline.
///
/// 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);
}
public interface IPersonalTimelineService : IBaseTimelineService
{
///
/// Get the timeline info.
///
/// 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);
}
}