2021-11-13 03:21:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Security.Claims;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Start.Server.Data.Services.Interfaces;
|
|
|
|
|
using Start.Server.Models;
|
|
|
|
|
|
|
|
|
|
namespace Start.Server.Controllers {
|
|
|
|
|
[Authorize]
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Route("[controller]")]
|
|
|
|
|
public class BookmarksController : ControllerBase {
|
|
|
|
|
private readonly IBookmarkService bookmarkService;
|
|
|
|
|
|
|
|
|
|
public BookmarksController(IBookmarkService bookmarkService) {
|
|
|
|
|
this.bookmarkService = bookmarkService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IList<BookmarkContainer> GetAllBookmarkContainers() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public BookmarkContainer GetBookmarkContainer(int bookmarkContainerId) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
2021-11-14 01:19:28 +00:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public (BookmarkStatus, Bookmark?) GetBookmark(int bookmarkId) {
|
|
|
|
|
return this.bookmarkService.GetBookmark(this.GetUserId(), bookmarkId);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-13 03:21:59 +00:00
|
|
|
|
[HttpPost]
|
2021-11-14 01:19:28 +00:00
|
|
|
|
public (BookmarkStatus, Bookmark?) CreateBookmark(string title, string url, string? notes,
|
2021-11-13 03:21:59 +00:00
|
|
|
|
int bookmarkGroupId) {
|
2021-11-14 01:19:28 +00:00
|
|
|
|
return this.bookmarkService.CreateBookmark(this.GetUserId(), title, url, notes,
|
|
|
|
|
bookmarkGroupId);
|
2021-11-13 03:21:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-14 01:19:28 +00:00
|
|
|
|
private string GetUserId() {
|
|
|
|
|
return this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
|
|
|
|
}
|
2021-11-13 03:21:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|