diff options
author | crupest <crupest@outlook.com> | 2020-02-02 00:31:33 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-02-02 00:31:33 +0800 |
commit | 9e84b1e9ad1f2a45cd3e09759c69989fdc588c3d (patch) | |
tree | 2d161307f76b29c52c60048cf4f65d354a967df3 /Timeline/Models | |
parent | 1c880744293c9f47ff1241109b72c035680251df (diff) | |
download | timeline-9e84b1e9ad1f2a45cd3e09759c69989fdc588c3d.tar.gz timeline-9e84b1e9ad1f2a45cd3e09759c69989fdc588c3d.tar.bz2 timeline-9e84b1e9ad1f2a45cd3e09759c69989fdc588c3d.zip |
...
Diffstat (limited to 'Timeline/Models')
-rw-r--r-- | Timeline/Models/Http/TimelineCommon.cs | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/Timeline/Models/Http/TimelineCommon.cs b/Timeline/Models/Http/TimelineCommon.cs index febb8186..0b2a714c 100644 --- a/Timeline/Models/Http/TimelineCommon.cs +++ b/Timeline/Models/Http/TimelineCommon.cs @@ -1,5 +1,7 @@ -using System;
+using Microsoft.AspNetCore.Mvc;
+using System;
using System.Collections.Generic;
+using Timeline.Controllers;
namespace Timeline.Models.Http
{
@@ -28,17 +30,41 @@ namespace Timeline.Models.Http public DateTime LastUpdated { get; set; } = default!;
}
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "This is a DTO class.")]
- public class BaseTimelineInfo
+ 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 Posts { get; set; } = default!;
}
- public class TimelineInfo : BaseTimelineInfo
+ public static class TimelineInfoExtensions
{
- public string Name { get; set; } = default!;
+ 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));
+
+ info._links = new TimelineInfoLinks
+ {
+ Posts = urlHelper.ActionLink(nameof(PersonalTimelineController.PostListGet), nameof(PersonalTimelineController)[0..^nameof(Controller).Length], new { info.Owner.Username })
+ };
+
+ return info;
+ }
}
}
|