aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers/TimelineController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-02-13 21:24:33 +0800
committercrupest <crupest@outlook.com>2021-02-13 21:24:33 +0800
commit50dbdde46eed6f2ff4c9691eea4414c1712af8e5 (patch)
treeaa0ee1272aa3e27462289fce0b2d5466d5049f96 /BackEnd/Timeline/Controllers/TimelineController.cs
parentc8bd19aacf9059f740df4f6fa9890127c20c1f6d (diff)
parent6a1495dc98f5ae5f89de58ed0ff0b500fc71ff5a (diff)
downloadtimeline-50dbdde46eed6f2ff4c9691eea4414c1712af8e5.tar.gz
timeline-50dbdde46eed6f2ff4c9691eea4414c1712af8e5.tar.bz2
timeline-50dbdde46eed6f2ff4c9691eea4414c1712af8e5.zip
Merge branch 'master' into frontend
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)