aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Controllers/TimelineController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-02-03 17:50:17 +0800
committercrupest <crupest@outlook.com>2020-02-03 17:50:17 +0800
commit5f93daed17338abbcade5eaba8936acbc4955b56 (patch)
tree9f9747d30d15abf8389527039db542c961135b1f /Timeline/Controllers/TimelineController.cs
parentbcf15408ca1a1a16ccaca959861e812e6b24a33d (diff)
downloadtimeline-5f93daed17338abbcade5eaba8936acbc4955b56.tar.gz
timeline-5f93daed17338abbcade5eaba8936acbc4955b56.tar.bz2
timeline-5f93daed17338abbcade5eaba8936acbc4955b56.zip
Add TimelineController.
Diffstat (limited to 'Timeline/Controllers/TimelineController.cs')
-rw-r--r--Timeline/Controllers/TimelineController.cs19
1 files changed, 17 insertions, 2 deletions
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<ActionResult<TimelineInfo>> 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());
+ }
+ }
}
}