diff options
author | crupest <crupest@outlook.com> | 2020-02-03 17:50:17 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-02-03 17:50:17 +0800 |
commit | 4b2569368073bbd556bbe71bd51807de91f814cb (patch) | |
tree | 9f9747d30d15abf8389527039db542c961135b1f /Timeline/Controllers | |
parent | 10985f0a26010988d26777d5a6d985b4fbc0a776 (diff) | |
download | timeline-4b2569368073bbd556bbe71bd51807de91f814cb.tar.gz timeline-4b2569368073bbd556bbe71bd51807de91f814cb.tar.bz2 timeline-4b2569368073bbd556bbe71bd51807de91f814cb.zip |
Add TimelineController.
Diffstat (limited to 'Timeline/Controllers')
-rw-r--r-- | Timeline/Controllers/PersonalTimelineController.cs | 2 | ||||
-rw-r--r-- | Timeline/Controllers/TimelineController.cs | 19 |
2 files changed, 18 insertions, 3 deletions
diff --git a/Timeline/Controllers/PersonalTimelineController.cs b/Timeline/Controllers/PersonalTimelineController.cs index 8cf098bf..b6c213d9 100644 --- a/Timeline/Controllers/PersonalTimelineController.cs +++ b/Timeline/Controllers/PersonalTimelineController.cs @@ -104,7 +104,7 @@ namespace Timeline.Controllers }
catch (UserNotExistException)
{
- return BadRequest(ErrorResponse.TimelineController.MemberPut_NotExist());
+ return BadRequest(ErrorResponse.TimelineCommon.MemberPut_NotExist());
}
}
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());
+ }
+ }
}
}
|