From 7936281edc1ac592cd318b8dccb37f3c4e7334e8 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 27 Aug 2020 01:13:31 +0800 Subject: Timeline title feature. --- Timeline/Models/Http/Timeline.cs | 4 ++++ Timeline/Models/Http/TimelineController.cs | 5 +++++ Timeline/Models/Timeline.cs | 2 ++ Timeline/Services/TimelineService.cs | 11 ++++++++++- 4 files changed, 21 insertions(+), 1 deletion(-) (limited to 'Timeline') diff --git a/Timeline/Models/Http/Timeline.cs b/Timeline/Models/Http/Timeline.cs index 6498fa74..3596af18 100644 --- a/Timeline/Models/Http/Timeline.cs +++ b/Timeline/Models/Http/Timeline.cs @@ -68,6 +68,10 @@ namespace Timeline.Models.Http /// public string UniqueId { get; set; } = default!; /// + /// Title. + /// + public string Title { get; set; } = default!; + /// /// Name of timeline. /// public string Name { get; set; } = default!; diff --git a/Timeline/Models/Http/TimelineController.cs b/Timeline/Models/Http/TimelineController.cs index aad361ee..95bae3e6 100644 --- a/Timeline/Models/Http/TimelineController.cs +++ b/Timeline/Models/Http/TimelineController.cs @@ -56,6 +56,11 @@ namespace Timeline.Models.Http /// public class TimelinePatchRequest { + /// + /// New title. Null for not change. + /// + public string? Title { get; set; } + /// /// New description. Null for not change. /// diff --git a/Timeline/Models/Timeline.cs b/Timeline/Models/Timeline.cs index 34c253a0..42906053 100644 --- a/Timeline/Models/Timeline.cs +++ b/Timeline/Models/Timeline.cs @@ -74,6 +74,7 @@ namespace Timeline.Models 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 User Owner { get; set; } = default!; public TimelineVisibility Visibility { get; set; } @@ -86,6 +87,7 @@ namespace Timeline.Models public class TimelineChangePropertyRequest { + public string? Title { get; set; } public string? Description { get; set; } public TimelineVisibility? Visibility { get; set; } } diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs index 01f7f5fd..2f0bf2c5 100644 --- a/Timeline/Services/TimelineService.cs +++ b/Timeline/Services/TimelineService.cs @@ -405,11 +405,14 @@ namespace Timeline.Services members.Add(await _userService.GetUserById(memberEntity.UserId)); } + var name = entity.Name ?? ("@" + owner.Username); + return new Models.Timeline { UniqueID = entity.UniqueId, - Name = entity.Name ?? ("@" + owner.Username), + Name = name, NameLastModified = entity.NameLastModified, + Title = string.IsNullOrEmpty(entity.Title) ? name : entity.Title, Description = entity.Description ?? "", Owner = owner, Visibility = entity.Visibility, @@ -834,6 +837,12 @@ namespace Timeline.Services var changed = false; + if (newProperties.Title != null) + { + changed = true; + timelineEntity.Title = newProperties.Title; + } + if (newProperties.Description != null) { changed = true; -- cgit v1.2.3