Use DTOs in controller
This commit is contained in:
parent
b52610e126
commit
106956157b
5 changed files with 56 additions and 11 deletions
24
Start/Server/Extensions/BookmarkMaps.cs
Normal file
24
Start/Server/Extensions/BookmarkMaps.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Start.Server.Models;
|
||||
using Start.Shared;
|
||||
|
||||
namespace Start.Server.Extensions {
|
||||
public static class BookmarkMaps {
|
||||
public static BookmarkDto MapToDto(this Bookmark bookmark) {
|
||||
return new BookmarkDto(bookmark.BookmarkId, bookmark.Title, bookmark.Url,
|
||||
bookmark.Notes);
|
||||
}
|
||||
|
||||
public static BookmarkGroupDto MapToDto(this BookmarkGroup bookmarkGroup) {
|
||||
return new BookmarkGroupDto(bookmarkGroup.BookmarkGroupId, bookmarkGroup.Title,
|
||||
bookmarkGroup.Color, bookmarkGroup.Bookmarks?.Select(b => b.MapToDto()).ToList());
|
||||
}
|
||||
|
||||
public static BookmarkContainerDto MapToDto(this BookmarkContainer bookmarkContainer) {
|
||||
return new BookmarkContainerDto(bookmarkContainer.BookmarkContainerId,
|
||||
bookmarkContainer.Title,
|
||||
bookmarkContainer.BookmarkGroups?.Select(bg => bg.MapToDto()).ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue