diff options
Diffstat (limited to 'BackEnd/Timeline/Controllers')
-rw-r--r-- | BackEnd/Timeline/Controllers/TimelineController.cs | 12 | ||||
-rw-r--r-- | BackEnd/Timeline/Controllers/TimelineV2Controller.cs | 33 |
2 files changed, 40 insertions, 5 deletions
diff --git a/BackEnd/Timeline/Controllers/TimelineController.cs b/BackEnd/Timeline/Controllers/TimelineController.cs index 42b8f210..7aeec02f 100644 --- a/BackEnd/Timeline/Controllers/TimelineController.cs +++ b/BackEnd/Timeline/Controllers/TimelineController.cs @@ -21,6 +21,7 @@ namespace Timeline.Controllers /// </summary>
[ApiController]
[Route("timelines")]
+ [CatchMultipleTimelineException]
[ProducesErrorResponseType(typeof(CommonResponse))]
public class TimelineController : MyControllerBase
{
@@ -117,12 +118,13 @@ namespace Timeline.Controllers /// <returns>The timeline info.</returns>
[HttpGet("{timeline}")]
[ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<HttpTimeline>> TimelineGet([FromRoute][GeneralTimelineName] string timeline)
- {
- var timelineId = await _service.GetTimelineIdByNameAsync(timeline);
- var t = await _service.GetTimelineAsync(timelineId);
- var result = await Map(t);
+ { + var timelineId = await _service.GetTimelineIdByNameAsync(timeline); + var t = await _service.GetTimelineAsync(timelineId); + var result = await Map(t); return result;
}
@@ -218,7 +220,7 @@ namespace Timeline.Controllers {
var userId = GetAuthUserId();
- var timeline = await _service.CreateTimelineAsync(body.Name, userId);
+ var timeline = await _service.CreateTimelineAsync(userId, body.Name);
var result = await Map(timeline);
return result;
}
diff --git a/BackEnd/Timeline/Controllers/TimelineV2Controller.cs b/BackEnd/Timeline/Controllers/TimelineV2Controller.cs new file mode 100644 index 00000000..7543c2a8 --- /dev/null +++ b/BackEnd/Timeline/Controllers/TimelineV2Controller.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Timeline.Entities; +using Timeline.Models.Http; +using Timeline.Services.Mapper; +using Timeline.Services.Timeline; + +namespace Timeline.Controllers +{ + [ApiController] + [Route("v2/timelines")] + public class TimelineV2Controller : MyControllerBase + { + private ITimelineService _timelineService; + private TimelineMapper _timelineMapper; + + public TimelineV2Controller(ITimelineService timelineService, TimelineMapper timelineMapper) + { + _timelineService = timelineService; + _timelineMapper = timelineMapper; + } + + [HttpGet("{owner}/{timeline}")] + public async Task<ActionResult<HttpTimeline>> Get([FromRoute] string owner, [FromRoute] string timeline) + { + var timelineId = await _timelineService.GetTimelineIdAsync(owner, timeline); + var t = await _timelineService.GetTimelineAsync(timelineId); + return await _timelineMapper.MapAsync(t, Url, User); + } + } +} + |