diff options
author | crupest <crupest@outlook.com> | 2020-11-27 00:07:09 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-11-27 00:07:09 +0800 |
commit | 3f4e88757f961532b84df85e86d21995655a29d4 (patch) | |
tree | 1dbb69aadcd4d3287ae0d2aad913365abc44a18e /BackEnd/Timeline/Models/TimelineInfo.cs | |
parent | c2ca954fc8bc0f12ad2ece715cb6c4a633a23119 (diff) | |
download | timeline-3f4e88757f961532b84df85e86d21995655a29d4.tar.gz timeline-3f4e88757f961532b84df85e86d21995655a29d4.tar.bz2 timeline-3f4e88757f961532b84df85e86d21995655a29d4.zip |
refactor: ...
Diffstat (limited to 'BackEnd/Timeline/Models/TimelineInfo.cs')
-rw-r--r-- | BackEnd/Timeline/Models/TimelineInfo.cs | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/BackEnd/Timeline/Models/TimelineInfo.cs b/BackEnd/Timeline/Models/TimelineInfo.cs new file mode 100644 index 00000000..440f6b81 --- /dev/null +++ b/BackEnd/Timeline/Models/TimelineInfo.cs @@ -0,0 +1,130 @@ +using System;
+using System.Collections.Generic;
+
+namespace Timeline.Models
+{
+ public enum TimelineVisibility
+ {
+ /// <summary>
+ /// All people including those without accounts.
+ /// </summary>
+ Public,
+ /// <summary>
+ /// Only people signed in.
+ /// </summary>
+ Register,
+ /// <summary>
+ /// Only member.
+ /// </summary>
+ Private
+ }
+
+ public static class TimelinePostContentTypes
+ {
+ public const string Text = "text";
+ public const string Image = "image";
+ }
+
+ public interface ITimelinePostContent
+ {
+ public string Type { get; }
+ }
+
+ public class TextTimelinePostContent : ITimelinePostContent
+ {
+ public TextTimelinePostContent(string text) { Text = text; }
+
+ public string Type { get; } = TimelinePostContentTypes.Text;
+ public string Text { get; set; }
+ }
+
+ public class ImageTimelinePostContent : ITimelinePostContent
+ {
+ public ImageTimelinePostContent(string dataTag) { DataTag = dataTag; }
+
+ public string Type { get; } = TimelinePostContentTypes.Image;
+
+ /// <summary>
+ /// The tag of the data. The tag of the entry in DataManager. Also the etag (not quoted).
+ /// </summary>
+ public string DataTag { get; set; }
+ }
+
+ public record TimelinePostInfo
+ {
+ public TimelinePostInfo()
+ {
+
+ }
+
+ public TimelinePostInfo(long id, ITimelinePostContent? content, DateTime time, UserInfo? author, DateTime lastUpdated, string timelineName)
+ {
+ Id = id;
+ Content = content;
+ Time = time;
+ Author = author;
+ LastUpdated = lastUpdated;
+ TimelineName = timelineName;
+ }
+
+ public long Id { get; set; }
+ public ITimelinePostContent? Content { get; set; }
+ public bool Deleted => Content == null;
+ public DateTime Time { get; set; }
+ public UserInfo? Author { get; set; }
+ public DateTime LastUpdated { get; set; }
+ public string TimelineName { get; set; } = default!;
+ }
+
+ public record TimelineInfo
+ {
+ public TimelineInfo()
+ {
+
+ }
+
+ public TimelineInfo(
+ string uniqueId,
+ string name,
+ DateTime nameLastModified,
+ string title,
+ string description,
+ UserInfo owner,
+ TimelineVisibility visibility,
+ List<UserInfo> members,
+ DateTime createTime,
+ DateTime lastModified)
+ {
+ UniqueId = uniqueId;
+ Name = name;
+ NameLastModified = nameLastModified;
+ Title = title;
+ Description = description;
+ Owner = owner;
+ Visibility = visibility;
+ Members = members;
+ CreateTime = createTime;
+ LastModified = lastModified;
+ }
+
+ public string UniqueId { get; set; } = default!;
+ public string Name { get; set; } = default!;
+ public DateTime NameLastModified { get; set; } = default!;
+ public string Title { get; set; } = default!;
+ public string Description { get; set; } = default!;
+ public UserInfo Owner { get; set; } = default!;
+ public TimelineVisibility Visibility { get; set; }
+#pragma warning disable CA2227 // Collection properties should be read only
+ public List<UserInfo> Members { get; set; } = default!;
+#pragma warning restore CA2227 // Collection properties should be read only
+ public DateTime CreateTime { get; set; } = default!;
+ public DateTime LastModified { get; set; } = default!;
+ }
+
+ public class TimelineChangePropertyRequest
+ {
+ public string? Title { get; set; }
+ public string? Description { get; set; }
+ public TimelineVisibility? Visibility { get; set; }
+ }
+}
|