From 4b2569368073bbd556bbe71bd51807de91f814cb Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 3 Feb 2020 17:50:17 +0800 Subject: Add TimelineController. --- Timeline/Controllers/TimelineController.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'Timeline/Controllers/TimelineController.cs') diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs index be271de7..d46189b8 100644 --- a/Timeline/Controllers/TimelineController.cs +++ b/Timeline/Controllers/TimelineController.cs @@ -102,7 +102,7 @@ namespace Timeline.Controllers } catch (UserNotExistException) { - return BadRequest(ErrorResponse.TimelineController.MemberPut_NotExist()); + return BadRequest(ErrorResponse.TimelineCommon.MemberPut_NotExist()); } } @@ -126,6 +126,21 @@ namespace Timeline.Controllers } } - // TODO: Create API . + [HttpPost("timelines")] + [Authorize] + public async Task> TimelineCreate([FromRoute] TimelineCreateRequest body) + { + var userId = this.GetUserId(); + + try + { + var timelineInfo = await _service.CreateTimeline(body.Name, userId); + return Ok(timelineInfo); + } + catch (ConflictException) + { + return BadRequest(ErrorResponse.TimelineCommon.NameConflict()); + } + } } } -- cgit v1.2.3