Finish filling out BookmarksController and fix routes

This commit is contained in:
Neil Brommer 2021-11-23 22:57:46 -08:00
parent ca9cb3caa0
commit d161c10a48

View file

@ -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();
}
}
}