diff options
Diffstat (limited to 'BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs')
-rw-r--r-- | BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs b/BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs index 7f620928..7bc02dc2 100644 --- a/BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs +++ b/BackEnd/Timeline/Controllers/V2/TimelineV2Controller.cs @@ -2,11 +2,9 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Timeline.Entities; using Timeline.Models.Http; using Timeline.Models.Validation; using Timeline.Services; -using Timeline.Services.Mapper; using Timeline.Services.Timeline; using Timeline.Services.User; @@ -17,27 +15,20 @@ namespace Timeline.Controllers.V2 public class TimelineV2Controller : V2ControllerBase { private ITimelineService _timelineService; - private IGenericMapper _mapper; private IUserService _userService; - public TimelineV2Controller(ITimelineService timelineService, IGenericMapper mapper, IUserService userService) + public TimelineV2Controller(ITimelineService timelineService, IUserService userService) { _timelineService = timelineService; - _mapper = mapper; _userService = userService; } - private Task<HttpTimeline> MapAsync(TimelineEntity entity) - { - return _mapper.MapAsync<HttpTimeline>(entity, Url, User); - } - [HttpGet("{owner}/{timeline}")] public async Task<ActionResult<HttpTimeline>> GetAsync([FromRoute][Username] string owner, [FromRoute][TimelineName] string timeline) { var timelineId = await _timelineService.GetTimelineIdAsync(owner, timeline); var t = await _timelineService.GetTimelineAsync(timelineId); - return await MapAsync(t); + return await MapAsync<HttpTimeline>(t); } [HttpPatch("{owner}/{timeline}")] @@ -54,9 +45,9 @@ namespace Timeline.Controllers.V2 { return Forbid(); } - await _timelineService.ChangePropertyAsync(timelineId, _mapper.AutoMapperMap<TimelineChangePropertyParams>(body)); + await _timelineService.ChangePropertyAsync(timelineId, AutoMapperMap<TimelineChangePropertyParams>(body)); var t = await _timelineService.GetTimelineAsync(timelineId); - return await MapAsync(t); + return await MapAsync<HttpTimeline>(t); } [HttpDelete("{owner}/{timeline}")] @@ -144,7 +135,7 @@ namespace Timeline.Controllers.V2 var authUserId = GetAuthUserId(); var authUser = await _userService.GetUserAsync(authUserId); var timeline = await _timelineService.CreateTimelineAsync(authUserId, body.Name); - var result = await MapAsync(timeline); + var result = await MapAsync<HttpTimeline>(timeline); return CreatedAtAction("Get", new { owner = authUser.Username, timeline = body.Name }, result); } } |