aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers/TimelineController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-04-28 19:20:40 +0800
committercrupest <crupest@outlook.com>2021-04-28 19:20:40 +0800
commite16c958e5ba47834dc1624e09ed8e5074a60d1c6 (patch)
treeaf8de5669e0ade7d1425d7c5599d438a6cf1c38c /BackEnd/Timeline/Controllers/TimelineController.cs
parent29453339a7ba744dc19f730ffbd71d6bff01f25b (diff)
downloadtimeline-e16c958e5ba47834dc1624e09ed8e5074a60d1c6.tar.gz
timeline-e16c958e5ba47834dc1624e09ed8e5074a60d1c6.tar.bz2
timeline-e16c958e5ba47834dc1624e09ed8e5074a60d1c6.zip
refator: ...
Diffstat (limited to 'BackEnd/Timeline/Controllers/TimelineController.cs')
-rw-r--r--BackEnd/Timeline/Controllers/TimelineController.cs16
1 files changed, 6 insertions, 10 deletions
diff --git a/BackEnd/Timeline/Controllers/TimelineController.cs b/BackEnd/Timeline/Controllers/TimelineController.cs
index c6b1f9ad..497d7893 100644
--- a/BackEnd/Timeline/Controllers/TimelineController.cs
+++ b/BackEnd/Timeline/Controllers/TimelineController.cs
@@ -1,5 +1,4 @@
-using AutoMapper;
-using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
@@ -28,18 +27,15 @@ namespace Timeline.Controllers
{
private readonly IUserService _userService;
private readonly ITimelineService _service;
-
- private readonly TimelineMapper _timelineMapper;
- private readonly IMapper _mapper;
+ private readonly IGenericMapper _mapper;
/// <summary>
///
/// </summary>
- public TimelineController(IUserService userService, ITimelineService service, TimelineMapper timelineMapper, IMapper mapper)
+ public TimelineController(IUserService userService, ITimelineService service, IGenericMapper mapper)
{
_userService = userService;
_service = service;
- _timelineMapper = timelineMapper;
_mapper = mapper;
}
@@ -47,12 +43,12 @@ namespace Timeline.Controllers
private Task<HttpTimeline> Map(TimelineEntity timeline)
{
- return _timelineMapper.MapToHttp(timeline, Url, this.GetOptionalUserId(), UserHasAllTimelineManagementPermission);
+ return _mapper.MapAsync<HttpTimeline>(timeline, Url, User);
}
private Task<List<HttpTimeline>> Map(List<TimelineEntity> timelines)
{
- return _timelineMapper.MapToHttp(timelines, Url, this.GetOptionalUserId(), UserHasAllTimelineManagementPermission);
+ return _mapper.MapListAsync<HttpTimeline>(timelines, Url, User);
}
/// <summary>
@@ -157,7 +153,7 @@ namespace Timeline.Controllers
try
{
- await _service.ChangePropertyAsync(timelineId, _mapper.Map<TimelineChangePropertyParams>(body));
+ await _service.ChangePropertyAsync(timelineId, _mapper.AutoMapperMap<TimelineChangePropertyParams>(body));
var t = await _service.GetTimelineAsync(timelineId);
var result = await Map(t);
return result;