diff options
author | crupest <crupest@outlook.com> | 2020-03-12 19:56:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-12 19:56:20 +0800 |
commit | d51954c2eaf07769e045270a02c19e46e01fe73f (patch) | |
tree | 70681348ddfc3bc8c3d9a92ae010a02020830573 /Timeline/Models/Http/TimelineCommon.cs | |
parent | eb9554b4fe78eaced12329e7fd7d8d62a58a1c6c (diff) | |
parent | 45527eb0c836d14725019c3facdff6c8391531cf (diff) | |
download | timeline-d51954c2eaf07769e045270a02c19e46e01fe73f.tar.gz timeline-d51954c2eaf07769e045270a02c19e46e01fe73f.tar.bz2 timeline-d51954c2eaf07769e045270a02c19e46e01fe73f.zip |
Merge pull request #69 from crupest/image
Post image feature.
Diffstat (limited to 'Timeline/Models/Http/TimelineCommon.cs')
-rw-r--r-- | Timeline/Models/Http/TimelineCommon.cs | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/Timeline/Models/Http/TimelineCommon.cs b/Timeline/Models/Http/TimelineCommon.cs deleted file mode 100644 index d0dfd837..00000000 --- a/Timeline/Models/Http/TimelineCommon.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using Timeline.Controllers;
-
-namespace Timeline.Models.Http
-{
- 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 class TimelinePostInfo
- {
- public long Id { get; set; }
- public string Content { get; set; } = default!;
- public DateTime Time { get; set; }
- public UserInfo Author { get; set; } = default!;
- public DateTime LastUpdated { get; set; } = default!;
- }
-
- public class TimelineInfo
- {
- public string? Name { get; set; }
- 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
-
-#pragma warning disable CA1707 // Identifiers should not contain underscores
- public TimelineInfoLinks? _links { get; set; }
-#pragma warning restore CA1707 // Identifiers should not contain underscores
- }
-
- public class TimelineInfoLinks
- {
- public string Self { get; set; } = default!;
- public string Posts { get; set; } = default!;
- }
-
- public static class TimelineInfoExtensions
- {
- public static TimelineInfo FillLinks(this TimelineInfo info, IUrlHelper urlHelper)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- if (urlHelper == null)
- throw new ArgumentNullException(nameof(urlHelper));
-
- if (string.IsNullOrEmpty(info.Name))
- {
- info._links = new TimelineInfoLinks
- {
- Self = urlHelper.ActionLink(nameof(PersonalTimelineController.TimelineGet), nameof(PersonalTimelineController)[0..^nameof(Controller).Length], new { info.Owner.Username }),
- Posts = urlHelper.ActionLink(nameof(PersonalTimelineController.PostListGet), nameof(PersonalTimelineController)[0..^nameof(Controller).Length], new { info.Owner.Username })
- };
- }
- else
- {
- info._links = new TimelineInfoLinks
- {
- Self = urlHelper.ActionLink(nameof(TimelineController.TimelineGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { info.Name }),
- Posts = urlHelper.ActionLink(nameof(TimelineController.PostListGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { info.Name })
- };
- }
-
- return info;
- }
- }
-}
|