Finish filling out BookmarksController and fix routes
This commit is contained in:
parent
ca9cb3caa0
commit
d161c10a48
|
@ -10,7 +10,7 @@ using Start.Shared;
|
||||||
namespace Start.Server.Controllers {
|
namespace Start.Server.Controllers {
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("[controller]/[action]")]
|
[Route("[controller]")]
|
||||||
public class BookmarksController : ControllerBase {
|
public class BookmarksController : ControllerBase {
|
||||||
private readonly IBookmarkGroupService bookmarkGroupService;
|
private readonly IBookmarkGroupService bookmarkGroupService;
|
||||||
private readonly IBookmarkService bookmarkService;
|
private readonly IBookmarkService bookmarkService;
|
||||||
|
@ -37,6 +37,7 @@ namespace Start.Server.Controllers {
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
[Route("Create")]
|
||||||
[ProducesResponseType(StatusCodes.Status201Created, Type = typeof(BookmarkDto))]
|
[ProducesResponseType(StatusCodes.Status201Created, Type = typeof(BookmarkDto))]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
public IActionResult CreateBookmark(string title, string url, string? notes,
|
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 }),
|
Url.Action(nameof(this.GetBookmark),new { bookmarkId = bookmark.BookmarkId }),
|
||||||
bookmark);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue