aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers/TimelineController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-02-13 15:46:02 +0800
committercrupest <crupest@outlook.com>2021-02-13 15:46:02 +0800
commit4538aa0be40316a967d6fbcbc08bc9670b9bbcf0 (patch)
tree9a3b573c2325fa500b565f82f734bd7540f765c9 /BackEnd/Timeline/Controllers/TimelineController.cs
parent01c3c5800f9b8a7b89d98b28ea748d496497c0b2 (diff)
downloadtimeline-4538aa0be40316a967d6fbcbc08bc9670b9bbcf0.tar.gz
timeline-4538aa0be40316a967d6fbcbc08bc9670b9bbcf0.tar.bz2
timeline-4538aa0be40316a967d6fbcbc08bc9670b9bbcf0.zip
feat: Add timeline manageable.
Diffstat (limited to 'BackEnd/Timeline/Controllers/TimelineController.cs')
-rw-r--r--BackEnd/Timeline/Controllers/TimelineController.cs19
1 files changed, 15 insertions, 4 deletions
diff --git a/BackEnd/Timeline/Controllers/TimelineController.cs b/BackEnd/Timeline/Controllers/TimelineController.cs
index 8479ca83..b20ab227 100644
--- a/BackEnd/Timeline/Controllers/TimelineController.cs
+++ b/BackEnd/Timeline/Controllers/TimelineController.cs
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using Timeline.Entities;
using Timeline.Filters;
using Timeline.Models;
using Timeline.Models.Http;
@@ -43,6 +44,16 @@ namespace Timeline.Controllers
private bool UserHasAllTimelineManagementPermission => this.UserHasPermission(UserPermission.AllTimelineManagement);
+ private Task<HttpTimeline> Map(TimelineEntity timeline)
+ {
+ return _timelineMapper.MapToHttp(timeline, Url, this.GetOptionalUserId(), UserHasAllTimelineManagementPermission);
+ }
+
+ private Task<List<HttpTimeline>> Map(List<TimelineEntity> timelines)
+ {
+ return _timelineMapper.MapToHttp(timelines, Url, this.GetOptionalUserId(), UserHasAllTimelineManagementPermission);
+ }
+
/// <summary>
/// List all timelines.
/// </summary>
@@ -102,7 +113,7 @@ namespace Timeline.Controllers
}
var timelines = await _service.GetTimelines(relationship, visibilityFilter);
- var result = await _timelineMapper.MapToHttp(timelines, Url, this.GetOptionalUserId());
+ var result = await Map(timelines);
return result;
}
@@ -118,7 +129,7 @@ namespace Timeline.Controllers
{
var timelineId = await _service.GetTimelineIdByName(timeline);
var t = await _service.GetTimeline(timelineId);
- var result = await _timelineMapper.MapToHttp(t, Url, this.GetOptionalUserId());
+ var result = await Map(t);
return result;
}
@@ -147,7 +158,7 @@ namespace Timeline.Controllers
{
await _service.ChangeProperty(timelineId, _mapper.Map<TimelineChangePropertyParams>(body));
var t = await _service.GetTimeline(timelineId);
- var result = await _timelineMapper.MapToHttp(t, Url, this.GetOptionalUserId());
+ var result = await Map(t);
return result;
}
catch (EntityAlreadyExistException)
@@ -237,7 +248,7 @@ namespace Timeline.Controllers
try
{
var timeline = await _service.CreateTimeline(body.Name, userId);
- var result = await _timelineMapper.MapToHttp(timeline, Url, this.GetOptionalUserId());
+ var result = await Map(timeline);
return result;
}
catch (EntityAlreadyExistException e) when (e.EntityName == EntityNames.Timeline)