From d161c10a489385cba7f5720b7287b0eb6d829524 Mon Sep 17 00:00:00 2001 From: Neil Brommer Date: Tue, 23 Nov 2021 22:57:46 -0800 Subject: [PATCH] Finish filling out BookmarksController and fix routes --- Start/Server/Controllers/BookmarksController.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Start/Server/Controllers/BookmarksController.cs b/Start/Server/Controllers/BookmarksController.cs index a11b2dc..6252996 100644 --- a/Start/Server/Controllers/BookmarksController.cs +++ b/Start/Server/Controllers/BookmarksController.cs @@ -10,7 +10,7 @@ using Start.Shared; namespace Start.Server.Controllers { [Authorize] [ApiController] - [Route("[controller]/[action]")] + [Route("[controller]")] public class BookmarksController : ControllerBase { private readonly IBookmarkGroupService bookmarkGroupService; private readonly IBookmarkService bookmarkService; @@ -37,6 +37,7 @@ namespace Start.Server.Controllers { } [HttpPost] + [Route("Create")] [ProducesResponseType(StatusCodes.Status201Created, Type = typeof(BookmarkDto))] [ProducesResponseType(StatusCodes.Status400BadRequest)] public IActionResult CreateBookmark(string title, string url, string? notes, @@ -52,5 +53,18 @@ namespace Start.Server.Controllers { Url.Action(nameof(this.GetBookmark),new { bookmarkId = bookmark.BookmarkId }), bookmark); } + + [HttpDelete] + [Route("Delete/{bookmarkId}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public IActionResult DeleteBookmark(int bookmarkId) { + var res = this.bookmarkService.DeleteBookmark(this.GetAuthorizedUserId(), bookmarkId); + + if (!res) + return NotFound(); + + return Ok(); + } } }