Fill out basic BookmarksController
This commit is contained in:
parent
d18dea826e
commit
6ec00b7d06
6 changed files with 50 additions and 18 deletions
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Start.Server.Data.Services.Interfaces;
|
||||
using Start.Server.Extensions;
|
||||
using Start.Server.Models;
|
||||
|
||||
namespace Start.Server.Controllers {
|
||||
|
|
@ -12,38 +10,40 @@ namespace Start.Server.Controllers {
|
|||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class BookmarksController : ControllerBase {
|
||||
private readonly IBookmarkContainerService bookmarkContainerService;
|
||||
private readonly IBookmarkGroupService bookmarkGroupService;
|
||||
private readonly IBookmarkService bookmarkService;
|
||||
|
||||
public BookmarksController(IBookmarkService bookmarkService) {
|
||||
private readonly string userId;
|
||||
|
||||
public BookmarksController(IBookmarkContainerService bookmarkContainerService,
|
||||
IBookmarkGroupService bookmarkGroupService, IBookmarkService bookmarkService) {
|
||||
this.bookmarkContainerService = bookmarkContainerService;
|
||||
this.bookmarkGroupService = bookmarkGroupService;
|
||||
this.bookmarkService = bookmarkService;
|
||||
|
||||
this.userId = this.GetAuthorizedUserId();
|
||||
}
|
||||
|
||||
/*
|
||||
[HttpGet]
|
||||
public IList<BookmarkContainer> GetAllBookmarkContainers() {
|
||||
|
||||
return this.bookmarkContainerService.GetUserBookmarkContainers(this.userId);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public BookmarkContainer GetBookmarkContainer(int bookmarkContainerId) {
|
||||
|
||||
public (BookmarkStatus, BookmarkContainer?) GetBookmarkContainer(int bookmarkContainerId) {
|
||||
return this.bookmarkContainerService.GetBookmarkContainer(this.userId, bookmarkContainerId, true, true);
|
||||
}
|
||||
*/
|
||||
|
||||
[HttpGet]
|
||||
public (BookmarkStatus, Bookmark?) GetBookmark(int bookmarkId) {
|
||||
return this.bookmarkService.GetBookmark(this.GetUserId(), bookmarkId);
|
||||
return this.bookmarkService.GetBookmark(this.userId, bookmarkId);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public (BookmarkStatus, Bookmark?) CreateBookmark(string title, string url, string? notes,
|
||||
int bookmarkGroupId) {
|
||||
return this.bookmarkService.CreateBookmark(this.GetUserId(), title, url, notes,
|
||||
bookmarkGroupId);
|
||||
}
|
||||
|
||||
private string GetUserId() {
|
||||
return this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
||||
return this.bookmarkService.CreateBookmark(this.userId, title, url, notes, bookmarkGroupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue