Add sorting columns
This commit is contained in:
parent
adf24cbd5c
commit
90adbcfb7c
34 changed files with 833 additions and 80 deletions
|
|
@ -12,8 +12,8 @@ namespace Start.Shared.Api {
|
|||
Task<ApiResponse<BookmarkContainerDto?>> GetBookmarkContainer(int bookmarkContainerId);
|
||||
|
||||
[Post("/Create")]
|
||||
Task<ApiResponse<BookmarkContainerDto?>> CreateBookmarkContainer(
|
||||
[Body(BodySerializationMethod.Serialized)] string title);
|
||||
Task<ApiResponse<BookmarkContainerDto?>> CreateBookmarkContainer(string title,
|
||||
int sortOrder);
|
||||
|
||||
[Delete("/Delete/{bookmarkContainerId}")]
|
||||
Task<HttpResponseMessage> DeleteBookmarkContainer(int bookmarkContainerId);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Start.Shared.Api {
|
|||
|
||||
[Post("/Create")]
|
||||
Task<ApiResponse<BookmarkGroupDto?>> CreateBookmarkGroup(string title, string color,
|
||||
int bookmarkContainerId);
|
||||
int sortOrder, int bookmarkContainerId);
|
||||
|
||||
[Delete("/Delete/{bookmarkGroupId}")]
|
||||
Task<HttpResponseMessage> DeleteBookmarkGroup(int bookmarkGroupId);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Start.Shared.Api {
|
|||
|
||||
[Post("/Create")]
|
||||
Task<ApiResponse<BookmarkDto?>> CreateBookmark(string title, string url, string? notes,
|
||||
int bookmarkGroupId);
|
||||
int sortOrder, int bookmarkGroupId);
|
||||
|
||||
[Delete("/Delete/{bookmarkId}")]
|
||||
Task<HttpResponseMessage> DeleteBookmark(int bookmarkId);
|
||||
|
|
|
|||
|
|
@ -8,20 +8,23 @@ namespace Start.Shared {
|
|||
[Required]
|
||||
[StringLength(300)]
|
||||
public string Title { get; set; }
|
||||
public int SortOrder { get; set; }
|
||||
|
||||
public IList<BookmarkGroupDto>? BookmarkGroups { get; set; }
|
||||
|
||||
public BookmarkContainerDto(string title) {
|
||||
public BookmarkContainerDto(string title, int sortOrder) {
|
||||
this.Title = title;
|
||||
this.SortOrder = sortOrder;
|
||||
}
|
||||
|
||||
public BookmarkContainerDto(int bookmarkContainerId, string title) : this(title) {
|
||||
public BookmarkContainerDto(int bookmarkContainerId, string title, int sortOrder)
|
||||
: this(title, sortOrder) {
|
||||
this.BookmarkContainerId = bookmarkContainerId;
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
public BookmarkContainerDto(int bookmarkContainerId, string title,
|
||||
IList<BookmarkGroupDto>? bookmarkGroups) : this(bookmarkContainerId, title) {
|
||||
public BookmarkContainerDto(int bookmarkContainerId, string title, int sortOrder,
|
||||
IList<BookmarkGroupDto>? bookmarkGroups) : this(bookmarkContainerId, title, sortOrder) {
|
||||
this.BookmarkGroups = bookmarkGroups;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,20 +10,23 @@ namespace Start.Shared {
|
|||
public string Url { get; set; }
|
||||
[StringLength(5000)]
|
||||
public string? Notes { get; set; }
|
||||
public int SortOrder { get; set; }
|
||||
|
||||
public int BookmarkGroupId { get; set; }
|
||||
|
||||
public BookmarkDto(string title, string url, string? notes, int bookmarkGroupId) {
|
||||
public BookmarkDto(string title, string url, string? notes, int sortOrder,
|
||||
int bookmarkGroupId) {
|
||||
this.Title = title;
|
||||
this.Url = url;
|
||||
this.Notes = notes;
|
||||
this.SortOrder = sortOrder;
|
||||
this.BookmarkGroupId = bookmarkGroupId;
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
public BookmarkDto(int bookmarkId, string title, string url, string? notes,
|
||||
public BookmarkDto(int bookmarkId, string title, string url, string? notes, int sortOrder,
|
||||
int bookmarkGroupId)
|
||||
: this(title, url, notes, bookmarkGroupId) {
|
||||
: this(title, url, notes, sortOrder, bookmarkGroupId) {
|
||||
this.BookmarkId = bookmarkId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,26 +11,29 @@ namespace Start.Shared {
|
|||
[Required(AllowEmptyStrings = false, ErrorMessage = "Color is required")]
|
||||
[StringLength(7)]
|
||||
public string Color { get; set; }
|
||||
public int SortOrder { get; set; }
|
||||
public int BookmarkContainerId { get; set; }
|
||||
|
||||
public IList<BookmarkDto>? Bookmarks { get; set; }
|
||||
|
||||
public BookmarkGroupDto(string title, string color, int bookmarkContainerId) {
|
||||
public BookmarkGroupDto(string title, string color, int sortOrder,
|
||||
int bookmarkContainerId) {
|
||||
this.Title = title;
|
||||
this.Color = color;
|
||||
this.SortOrder = sortOrder;
|
||||
this.BookmarkContainerId = bookmarkContainerId;
|
||||
}
|
||||
|
||||
public BookmarkGroupDto(int bookmarkGroupId, string title, string color,
|
||||
public BookmarkGroupDto(int bookmarkGroupId, string title, string color, int sortOrder,
|
||||
int bookmarkContainerId)
|
||||
: this(title, color, bookmarkContainerId) {
|
||||
: this(title, color, sortOrder, bookmarkContainerId) {
|
||||
this.BookmarkGroupId = bookmarkGroupId;
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
public BookmarkGroupDto(int bookmarkGroupId, string title, string color,
|
||||
public BookmarkGroupDto(int bookmarkGroupId, string title, string color, int sortOrder,
|
||||
int bookmarkContainerId, IList<BookmarkDto>? bookmarks)
|
||||
: this(bookmarkGroupId, title, color, bookmarkContainerId) {
|
||||
: this(bookmarkGroupId, title, color, sortOrder, bookmarkContainerId) {
|
||||
this.Bookmarks = bookmarks;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
Start/Shared/SortingExtensions.cs
Normal file
27
Start/Shared/SortingExtensions.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Start.Shared {
|
||||
public static class SortingExtensions {
|
||||
public static IEnumerable<BookmarkContainerDto> SortContainers(
|
||||
this IEnumerable<BookmarkContainerDto> bookmarkContainers) {
|
||||
return bookmarkContainers
|
||||
.OrderBy(bc => bc.SortOrder)
|
||||
.ThenBy(bc => bc.BookmarkContainerId);
|
||||
}
|
||||
|
||||
public static IEnumerable<BookmarkGroupDto> SortGroups(
|
||||
this IEnumerable<BookmarkGroupDto> bookmarkGroups) {
|
||||
return bookmarkGroups
|
||||
.OrderBy(bg => bg.SortOrder)
|
||||
.ThenBy(bg => bg.BookmarkGroupId);
|
||||
}
|
||||
|
||||
public static IEnumerable<BookmarkDto> SortBookmarks(
|
||||
this IEnumerable<BookmarkDto> bookmarks) {
|
||||
return bookmarks
|
||||
.OrderBy(b => b.SortOrder)
|
||||
.ThenBy(b => b.BookmarkId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue