From 5658347ebafdae2bb82e96f57299e40ddec58f28 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 12 Jul 2020 15:54:09 +0800 Subject: Add api in service. --- Timeline/Services/TimelineService.cs | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'Timeline/Services/TimelineService.cs') diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs index a0d72ad3..eafb0088 100644 --- a/Timeline/Services/TimelineService.cs +++ b/Timeline/Services/TimelineService.cs @@ -66,6 +66,32 @@ namespace Timeline.Services /// public interface ITimelineService { + /// + /// Get the timeline last modified time (not include name change). + /// + /// The name of the timeline. + /// The timeline info. + /// Thrown when is null. + /// Throw when is of bad format. + /// + /// Thrown when timeline with name does not exist. + /// If it is a personal timeline, then inner exception is . + /// + Task GetTimelineLastModifiedTime(string timelineName); + + /// + /// Get the timeline unique id. + /// + /// The name of the timeline. + /// The timeline info. + /// Thrown when is null. + /// Throw when is of bad format. + /// + /// Thrown when timeline with name does not exist. + /// If it is a personal timeline, then inner exception is . + /// + Task GetTimelineUniqueId(string timelineName); + /// /// Get the timeline info. /// @@ -497,6 +523,30 @@ namespace Timeline.Services } } + public async Task GetTimelineLastModifiedTime(string timelineName) + { + if (timelineName == null) + throw new ArgumentNullException(nameof(timelineName)); + + var timelineId = await FindTimelineId(timelineName); + + var timelineEntity = await _database.Timelines.Where(t => t.Id == timelineId).Select(t => new { t.LastModified }).SingleAsync(); + + return timelineEntity.LastModified; + } + + public async Task GetTimelineUniqueId(string timelineName) + { + if (timelineName == null) + throw new ArgumentNullException(nameof(timelineName)); + + var timelineId = await FindTimelineId(timelineName); + + var timelineEntity = await _database.Timelines.Where(t => t.Id == timelineId).Select(t => new { t.UniqueId }).SingleAsync(); + + return timelineEntity.UniqueId; + } + public async Task GetTimeline(string timelineName) { if (timelineName == null) -- cgit v1.2.3