blob: 7543c2a8e82e389247a4e7001d9a09c9e7bc1298 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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);
}
}
}
|