diff options
author | crupest <crupest@outlook.com> | 2021-02-02 18:59:41 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-02-02 18:59:41 +0800 |
commit | 0a0a61b60544a135a61394953bb5bb9dbbfeb241 (patch) | |
tree | 6e0ded513facfa3b8558aa8996284a10503e3099 /BackEnd/Timeline/Services/TimelineService.cs | |
parent | 27e6b7be9bce006da6aae651d9903573cf3fd180 (diff) | |
download | timeline-0a0a61b60544a135a61394953bb5bb9dbbfeb241.tar.gz timeline-0a0a61b60544a135a61394953bb5bb9dbbfeb241.tar.bz2 timeline-0a0a61b60544a135a61394953bb5bb9dbbfeb241.zip |
...
Diffstat (limited to 'BackEnd/Timeline/Services/TimelineService.cs')
-rw-r--r-- | BackEnd/Timeline/Services/TimelineService.cs | 18 |
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();
|