Use DTOs in controller
This commit is contained in:
parent
b52610e126
commit
106956157b
5 changed files with 56 additions and 11 deletions
|
|
@ -1,9 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Start.Server.Data.Services.Interfaces;
|
||||
using Start.Server.Extensions;
|
||||
using Start.Server.Models;
|
||||
using Start.Shared;
|
||||
|
||||
namespace Start.Server.Controllers {
|
||||
[Authorize]
|
||||
|
|
@ -26,24 +28,43 @@ namespace Start.Server.Controllers {
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
public IList<BookmarkContainer> GetAllBookmarkContainers() {
|
||||
return this.bookmarkContainerService.GetUserBookmarkContainers(this.userId);
|
||||
public IList<BookmarkContainerDto> GetAllBookmarkContainers() {
|
||||
return this.bookmarkContainerService.GetUserBookmarkContainers(this.userId)
|
||||
.Select(bc => bc.MapToDto())
|
||||
.ToList();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public (BookmarkStatus, BookmarkContainer?) GetBookmarkContainer(int bookmarkContainerId) {
|
||||
return this.bookmarkContainerService.GetBookmarkContainer(this.userId, bookmarkContainerId, true, true);
|
||||
public (BookmarkStatus, BookmarkContainerDto?) GetBookmarkContainer(int bookmarkContainerId) {
|
||||
(BookmarkStatus status, BookmarkContainer? container) = this.bookmarkContainerService
|
||||
.GetBookmarkContainer(this.userId, bookmarkContainerId, true, true);
|
||||
|
||||
return (status, container?.MapToDto());
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public (BookmarkStatus, Bookmark?) GetBookmark(int bookmarkId) {
|
||||
return this.bookmarkService.GetBookmark(this.userId, bookmarkId);
|
||||
public (BookmarkStatus, BookmarkDto?) GetBookmark(int bookmarkId) {
|
||||
(BookmarkStatus status, Bookmark? bookmark) = this.bookmarkService
|
||||
.GetBookmark(this.userId, bookmarkId);
|
||||
|
||||
return (status, bookmark?.MapToDto());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public (BookmarkStatus, Bookmark?) CreateBookmark(string title, string url, string? notes,
|
||||
public (BookmarkStatus, BookmarkDto?) CreateBookmark(string title, string url, string? notes,
|
||||
int bookmarkGroupId) {
|
||||
return this.bookmarkService.CreateBookmark(this.userId, title, url, notes, bookmarkGroupId);
|
||||
(BookmarkStatus status, Bookmark? bookmark) = this.bookmarkService
|
||||
.CreateBookmark(this.userId, title, url, notes, bookmarkGroupId);
|
||||
|
||||
return (status, bookmark?.MapToDto());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public (BookmarkStatus, BookmarkContainerDto?) CreateBookmarkContainer(string title) {
|
||||
(BookmarkStatus status, BookmarkContainer? container) = this
|
||||
.bookmarkContainerService.CreateBookmarkContainer(this.userId, title);
|
||||
|
||||
return (status, container?.MapToDto());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue