aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers/TimelineController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-02-13 16:01:20 +0800
committerGitHub <noreply@github.com>2021-02-13 16:01:20 +0800
commit42034bfb60c03b30dec6ddc93d35ced29070b0e7 (patch)
treefe1aaea4f34c227b2bcf5fdad77c7e2a85b7923b /BackEnd/Timeline/Controllers/TimelineController.cs
parent99d525560f6aefa5f5fb63e3ba2fff3b557d61f6 (diff)
parent2d9ca08366d91c22877cee143f43a062d4efda2d (diff)
downloadtimeline-42034bfb60c03b30dec6ddc93d35ced29070b0e7.tar.gz
timeline-42034bfb60c03b30dec6ddc93d35ced29070b0e7.tar.bz2
timeline-42034bfb60c03b30dec6ddc93d35ced29070b0e7.zip
Merge pull request #273 from crupest/backend
User permission related field in http.
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)