diff options
author | crupest <crupest@outlook.com> | 2020-02-04 16:13:53 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-02-04 16:13:53 +0800 |
commit | e5cf0da3976116cd575e884fb8f191f225fe9301 (patch) | |
tree | 2e14a75e8eb6d90325ca3fd114cbfc6478d34258 | |
parent | e5fb17ddfc3d1ecf0b283c8cc1a91fb2a2a03236 (diff) | |
download | timeline-e5cf0da3976116cd575e884fb8f191f225fe9301.tar.gz timeline-e5cf0da3976116cd575e884fb8f191f225fe9301.tar.bz2 timeline-e5cf0da3976116cd575e884fb8f191f225fe9301.zip |
Add self link in entities.
-rw-r--r-- | Timeline/Models/Http/TimelineCommon.cs | 3 | ||||
-rw-r--r-- | Timeline/Models/Http/UserInfo.cs | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/Timeline/Models/Http/TimelineCommon.cs b/Timeline/Models/Http/TimelineCommon.cs index 1cb47dac..6b857862 100644 --- a/Timeline/Models/Http/TimelineCommon.cs +++ b/Timeline/Models/Http/TimelineCommon.cs @@ -47,6 +47,7 @@ namespace Timeline.Models.Http public class TimelineInfoLinks
{
+ public string Self { get; set; } = default!;
public string Posts { get; set; } = default!;
}
@@ -61,6 +62,7 @@ namespace Timeline.Models.Http 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 })
};
@@ -76,6 +78,7 @@ namespace Timeline.Models.Http 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 })
};
diff --git a/Timeline/Models/Http/UserInfo.cs b/Timeline/Models/Http/UserInfo.cs index 0d1d702b..68c6d8bd 100644 --- a/Timeline/Models/Http/UserInfo.cs +++ b/Timeline/Models/Http/UserInfo.cs @@ -19,6 +19,7 @@ namespace Timeline.Models.Http public class UserInfoLinks
{
+ public string Self { get; set; } = default!;
public string Avatar { get; set; } = default!;
public string Timeline { get; set; } = default!;
}
@@ -42,6 +43,7 @@ namespace Timeline.Models.Http var urlHelper = _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext);
var result = new UserInfoLinks
{
+ Self = urlHelper.ActionLink(nameof(UserController.Get), nameof(UserController)[0..^nameof(Controller).Length], new { destination.Username }),
Avatar = urlHelper.ActionLink(nameof(UserAvatarController.Get), nameof(UserAvatarController)[0..^nameof(Controller).Length], new { destination.Username }),
Timeline = urlHelper.ActionLink(nameof(PersonalTimelineController.TimelineGet), nameof(PersonalTimelineController)[0..^nameof(Controller).Length], new { destination.Username })
};
|