BlazorStart/Start/Server/Extensions/BookmarkMaps.cs

25 lines
979 B
C#
Raw Normal View History

2021-12-05 23:50:48 +00:00
using System.Linq;
2021-11-16 05:44:16 +00:00
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,
2022-04-19 20:04:38 +00:00
bookmark.Notes, bookmark.SortOrder, bookmark.BookmarkGroupId);
2021-11-16 05:44:16 +00:00
}
public static BookmarkGroupDto MapToDto(this BookmarkGroup bookmarkGroup) {
return new BookmarkGroupDto(bookmarkGroup.BookmarkGroupId, bookmarkGroup.Title,
2022-04-19 20:04:38 +00:00
bookmarkGroup.Color, bookmarkGroup.SortOrder, bookmarkGroup.BookmarkContainerId,
2021-12-05 23:50:48 +00:00
bookmarkGroup.Bookmarks?.Select(b => b.MapToDto()).ToList());
2021-11-16 05:44:16 +00:00
}
public static BookmarkContainerDto MapToDto(this BookmarkContainer bookmarkContainer) {
return new BookmarkContainerDto(bookmarkContainer.BookmarkContainerId,
2022-04-19 20:04:38 +00:00
bookmarkContainer.Title, bookmarkContainer.SortOrder,
2021-11-16 05:44:16 +00:00
bookmarkContainer.BookmarkGroups?.Select(bg => bg.MapToDto()).ToList());
}
}
}