aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Models/Timeline.cs
blob: 52f38e42dbe4b2704551995cdfd8370a70ed19e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;

namespace TimelineApp.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;
        public string DataTag { get; set; }
    }

    public class TimelinePost
    {
        public long Id { get; set; }
        public ITimelinePostContent Content { get; set; } = default!;
        public DateTime Time { get; set; }
        public User Author { get; set; } = default!;
        public DateTime LastUpdated { get; set; } = default!;
    }

    public class Timeline
    {
        public string Name { get; set; } = default!;
        public string Description { get; set; } = default!;
        public User Owner { get; set; } = default!;
        public TimelineVisibility Visibility { get; set; }
#pragma warning disable CA2227 // Collection properties should be read only
        public List<User> Members { get; set; } = default!;
#pragma warning restore CA2227 // Collection properties should be read only
    }

    public class TimelineChangePropertyRequest
    {
        public string? Description { get; set; }
        public TimelineVisibility? Visibility { get; set; }
    }
}