aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-01-07 20:36:57 +0800
committercrupest <crupest@outlook.com>2021-01-07 20:36:57 +0800
commite701f8bab033dd364673215e66d58a1cb9fea339 (patch)
tree077b1c58c1f406e434e0e5857fdb06dc8deb5c22 /BackEnd/Timeline/Controllers
parentd5c2e1bd1573325e5585f5cf7279bd7592dbfeee (diff)
downloadtimeline-e701f8bab033dd364673215e66d58a1cb9fea339.tar.gz
timeline-e701f8bab033dd364673215e66d58a1cb9fea339.tar.bz2
timeline-e701f8bab033dd364673215e66d58a1cb9fea339.zip
refactor: Highlight and bookmark service now use timeline id.
Diffstat (limited to 'BackEnd/Timeline/Controllers')
-rw-r--r--BackEnd/Timeline/Controllers/BookmarkTimelineController.cs17
-rw-r--r--BackEnd/Timeline/Controllers/HighlightTimelineController.cs17
2 files changed, 20 insertions, 14 deletions
diff --git a/BackEnd/Timeline/Controllers/BookmarkTimelineController.cs b/BackEnd/Timeline/Controllers/BookmarkTimelineController.cs
index 64cb8afa..4313115e 100644
--- a/BackEnd/Timeline/Controllers/BookmarkTimelineController.cs
+++ b/BackEnd/Timeline/Controllers/BookmarkTimelineController.cs
@@ -52,12 +52,13 @@ namespace Timeline.Controllers
[ProducesResponseType(200)]
[ProducesResponseType(400)]
[ProducesResponseType(401)]
- public async Task<ActionResult> Put([GeneralTimelineName] string timeline)
+ public async Task<ActionResult<CommonPutResponse>> Put([GeneralTimelineName] string timeline)
{
try
{
- await _service.AddBookmark(this.GetUserId(), timeline);
- return Ok();
+ var timelineId = await _timelineService.GetTimelineIdByName(timeline);
+ var create = await _service.AddBookmark(this.GetUserId(), timelineId);
+ return CommonPutResponse.Create(create);
}
catch (TimelineNotExistException)
{
@@ -74,12 +75,13 @@ namespace Timeline.Controllers
[ProducesResponseType(200)]
[ProducesResponseType(400)]
[ProducesResponseType(401)]
- public async Task<ActionResult> Delete([GeneralTimelineName] string timeline)
+ public async Task<ActionResult<CommonDeleteResponse>> Delete([GeneralTimelineName] string timeline)
{
try
{
- await _service.RemoveBookmark(this.GetUserId(), timeline);
- return Ok();
+ var timelineId = await _timelineService.GetTimelineIdByName(timeline);
+ var delete = await _service.RemoveBookmark(this.GetUserId(), timelineId);
+ return CommonDeleteResponse.Create(delete);
}
catch (TimelineNotExistException)
{
@@ -100,7 +102,8 @@ namespace Timeline.Controllers
{
try
{
- await _service.MoveBookmark(this.GetUserId(), request.Timeline, request.NewPosition!.Value);
+ var timelineId = await _timelineService.GetTimelineIdByName(request.Timeline);
+ await _service.MoveBookmark(this.GetUserId(), timelineId, request.NewPosition!.Value);
return Ok();
}
catch (TimelineNotExistException)
diff --git a/BackEnd/Timeline/Controllers/HighlightTimelineController.cs b/BackEnd/Timeline/Controllers/HighlightTimelineController.cs
index 685ec16f..cc19cada 100644
--- a/BackEnd/Timeline/Controllers/HighlightTimelineController.cs
+++ b/BackEnd/Timeline/Controllers/HighlightTimelineController.cs
@@ -51,12 +51,13 @@ namespace Timeline.Controllers
[ProducesResponseType(400)]
[ProducesResponseType(401)]
[ProducesResponseType(403)]
- public async Task<ActionResult> Put([GeneralTimelineName] string timeline)
+ public async Task<ActionResult<CommonPutResponse>> Put([GeneralTimelineName] string timeline)
{
try
{
- await _service.AddHighlightTimeline(timeline, this.GetUserId());
- return Ok();
+ var timelineId = await _timelineService.GetTimelineIdByName(timeline);
+ var create = await _service.AddHighlightTimeline(timelineId, this.GetUserId());
+ return CommonPutResponse.Create(create);
}
catch (TimelineNotExistException)
{
@@ -74,12 +75,13 @@ namespace Timeline.Controllers
[ProducesResponseType(400)]
[ProducesResponseType(401)]
[ProducesResponseType(403)]
- public async Task<ActionResult> Delete([GeneralTimelineName] string timeline)
+ public async Task<ActionResult<CommonDeleteResponse>> Delete([GeneralTimelineName] string timeline)
{
try
{
- await _service.RemoveHighlightTimeline(timeline, this.GetUserId());
- return Ok();
+ var timelineId = await _timelineService.GetTimelineIdByName(timeline);
+ var delete = await _service.RemoveHighlightTimeline(timelineId, this.GetUserId());
+ return CommonDeleteResponse.Create(delete);
}
catch (TimelineNotExistException)
{
@@ -100,7 +102,8 @@ namespace Timeline.Controllers
{
try
{
- await _service.MoveHighlightTimeline(body.Timeline, body.NewPosition!.Value);
+ var timelineId = await _timelineService.GetTimelineIdByName(body.Timeline);
+ await _service.MoveHighlightTimeline(timelineId, body.NewPosition!.Value);
return Ok();
}
catch (TimelineNotExistException)