diff options
author | crupest <crupest@outlook.com> | 2021-01-07 20:14:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-07 20:14:55 +0800 |
commit | e02871ff8bba7fccebdaaeea29141ed5e3289c09 (patch) | |
tree | 67128b91d6cfd08c54c9e745e7bf2abbdf1f20f4 /BackEnd/Timeline/Controllers/TimelineController.cs | |
parent | 5ad1b1f0191ee1131e7808c8fcb0484ba29c0d4d (diff) | |
parent | ffe44ba70c9e5c6a01179c7e2f4185543cbc441c (diff) | |
download | timeline-e02871ff8bba7fccebdaaeea29141ed5e3289c09.tar.gz timeline-e02871ff8bba7fccebdaaeea29141ed5e3289c09.tar.bz2 timeline-e02871ff8bba7fccebdaaeea29141ed5e3289c09.zip |
Merge pull request #203 from crupest/back-dev
refactor: Make mapper a service. Fix #202.
Diffstat (limited to 'BackEnd/Timeline/Controllers/TimelineController.cs')
-rw-r--r-- | BackEnd/Timeline/Controllers/TimelineController.cs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/BackEnd/Timeline/Controllers/TimelineController.cs b/BackEnd/Timeline/Controllers/TimelineController.cs index b1401a03..efc49952 100644 --- a/BackEnd/Timeline/Controllers/TimelineController.cs +++ b/BackEnd/Timeline/Controllers/TimelineController.cs @@ -30,16 +30,18 @@ namespace Timeline.Controllers private readonly ITimelineService _service;
private readonly ITimelinePostService _postService;
+ private readonly TimelineMapper _timelineMapper;
private readonly IMapper _mapper;
/// <summary>
///
/// </summary>
- public TimelineController(IUserService userService, ITimelineService service, ITimelinePostService timelinePostService, IMapper mapper)
+ public TimelineController(IUserService userService, ITimelineService service, ITimelinePostService timelinePostService, TimelineMapper timelineMapper, IMapper mapper)
{
_userService = userService;
_service = service;
_postService = timelinePostService;
+ _timelineMapper = timelineMapper;
_mapper = mapper;
}
@@ -107,7 +109,7 @@ namespace Timeline.Controllers }
var timelines = await _service.GetTimelines(relationship, visibilityFilter);
- var result = timelines.MapToHttp(Url);
+ var result = await _timelineMapper.MapToHttp(timelines, Url);
return result;
}
@@ -166,7 +168,7 @@ namespace Timeline.Controllers else
{
var t = await _service.GetTimeline(timelineId);
- var result = t.MapToHttp(Url);
+ var result = await _timelineMapper.MapToHttp(t, Url);
return result;
}
}
@@ -193,7 +195,7 @@ namespace Timeline.Controllers var posts = await _postService.GetPosts(timelineId, modifiedSince, includeDeleted ?? false);
- var result = posts.MapToHttp(timeline, Url);
+ var result = await _timelineMapper.MapToHttp(posts, timeline, Url);
return result;
}
@@ -304,7 +306,7 @@ namespace Timeline.Controllers return BadRequest(ErrorResponse.Common.CustomMessage_InvalidModel(Resources.Messages.TimelineController_ContentUnknownType));
}
- var result = post.MapToHttp(timeline, Url);
+ var result = await _timelineMapper.MapToHttp(post, timeline, Url);
return result;
}
@@ -361,7 +363,7 @@ namespace Timeline.Controllers }
await _service.ChangeProperty(timelineId, _mapper.Map<TimelineChangePropertyParams>(body));
var t = await _service.GetTimeline(timelineId);
- var result = t.MapToHttp(Url);
+ var result = await _timelineMapper.MapToHttp(t, Url);
return result;
}
@@ -446,7 +448,7 @@ namespace Timeline.Controllers try
{
var timeline = await _service.CreateTimeline(body.Name, userId);
- var result = timeline.MapToHttp(Url);
+ var result = await _timelineMapper.MapToHttp(timeline, Url);
return result;
}
catch (EntityAlreadyExistException e) when (e.EntityName == EntityNames.Timeline)
@@ -505,7 +507,7 @@ namespace Timeline.Controllers {
await _service.ChangeTimelineName(timelineId, body.NewName);
var timeline = await _service.GetTimeline(timelineId);
- return Ok(timeline.MapToHttp(Url));
+ return await _timelineMapper.MapToHttp(timeline, Url);
}
catch (EntityAlreadyExistException)
{
|