aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Services/TimelineService.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-02-04 21:39:03 +0800
committerGitHub <noreply@github.com>2021-02-04 21:39:03 +0800
commit76d8616a6ba18f2bf86c46d865a9426e5accf55f (patch)
treeae0a8eb5f5a2d35114247f44a35e35e20aa2dee7 /BackEnd/Timeline/Services/TimelineService.cs
parent85247119bb82189baf100cd369e2f5993ee9d296 (diff)
parentc09ec62c64fe2d7cd09f7a2d9989ad96b43606a3 (diff)
downloadtimeline-76d8616a6ba18f2bf86c46d865a9426e5accf55f.tar.gz
timeline-76d8616a6ba18f2bf86c46d865a9426e5accf55f.tar.bz2
timeline-76d8616a6ba18f2bf86c46d865a9426e5accf55f.zip
Merge pull request #244 from crupest/color
Backend: Color
Diffstat (limited to 'BackEnd/Timeline/Services/TimelineService.cs')
-rw-r--r--BackEnd/Timeline/Services/TimelineService.cs18
1 files changed, 18 insertions, 0 deletions
diff --git a/BackEnd/Timeline/Services/TimelineService.cs b/BackEnd/Timeline/Services/TimelineService.cs
index f4141752..bed1c99b 100644
--- a/BackEnd/Timeline/Services/TimelineService.cs
+++ b/BackEnd/Timeline/Services/TimelineService.cs
@@ -53,6 +53,7 @@ namespace Timeline.Services
public string? Title { get; set; }
public string? Description { get; set; }
public TimelineVisibility? Visibility { get; set; }
+ public string? Color { get; set; }
}
/// <summary>
@@ -186,6 +187,8 @@ namespace Timeline.Services
private readonly TimelineNameValidator _timelineNameValidator = new TimelineNameValidator();
+ private readonly ColorValidator _colorValidator = new ColorValidator();
+
private void ValidateTimelineName(string name, string paramName)
{
if (!_timelineNameValidator.Validate(name, out var message))
@@ -212,6 +215,15 @@ namespace Timeline.Services
if (newProperties.Name is not null)
ValidateTimelineName(newProperties.Name, nameof(newProperties));
+ if (newProperties.Color is not null)
+ {
+ var (result, message) = _colorValidator.Validate(newProperties.Color);
+ if (!result)
+ {
+ throw new ArgumentException(message, nameof(newProperties));
+ }
+ }
+
var entity = await _database.Timelines.Where(t => t.Id == id).SingleOrDefaultAsync();
if (entity is null)
@@ -251,6 +263,12 @@ namespace Timeline.Services
entity.Visibility = newProperties.Visibility.Value;
}
+ if (newProperties.Color is not null)
+ {
+ changed = true;
+ entity.Color = newProperties.Color;
+ }
+
if (changed)
{
var currentTime = _clock.GetCurrentTime();