From be8cbe2c4ddf2076cc02bcb2feb1a70d30a4bda0 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 3 Feb 2020 18:18:45 +0800 Subject: Finish normal timeline development. --- Timeline/Controllers/TimelineController.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Timeline/Controllers') diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs index d46189b8..a514ccd9 100644 --- a/Timeline/Controllers/TimelineController.cs +++ b/Timeline/Controllers/TimelineController.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading.Tasks; +using Timeline.Filters; using Timeline.Models.Http; using Timeline.Models.Validation; using Timeline.Services; @@ -11,6 +12,7 @@ using Timeline.Services; namespace Timeline.Controllers { [ApiController] + [CatchTimelineNotExistException] public class TimelineController : Controller { private readonly ILogger _logger; @@ -26,7 +28,8 @@ namespace Timeline.Controllers [HttpGet("timelines/{name}")] public async Task> TimelineGet([FromRoute][TimelineName] string name) { - return (await _service.GetTimeline(name)).FillLinksForNormalTimeline(Url); + var result = (await _service.GetTimeline(name)).FillLinksForNormalTimeline(Url); + return Ok(result); } [HttpGet("timelines/{name}/posts")] @@ -128,13 +131,13 @@ namespace Timeline.Controllers [HttpPost("timelines")] [Authorize] - public async Task> TimelineCreate([FromRoute] TimelineCreateRequest body) + public async Task> TimelineCreate([FromBody] TimelineCreateRequest body) { var userId = this.GetUserId(); try { - var timelineInfo = await _service.CreateTimeline(body.Name, userId); + var timelineInfo = (await _service.CreateTimeline(body.Name, userId)).FillLinksForNormalTimeline(Url); return Ok(timelineInfo); } catch (ConflictException) -- cgit v1.2.3