Add creating bookmark groups

This commit is contained in:
Neil Brommer 2021-12-05 15:50:48 -08:00
parent d997655b59
commit 7841d1d1a8
28 changed files with 692 additions and 114 deletions

View file

@ -0,0 +1,17 @@
using System.Net.Http;
using System.Threading.Tasks;
using Refit;
namespace Start.Shared.Api {
public interface IBookmarkGroupsApi {
[Get("/{bookmarkGroupId}")]
Task<ApiResponse<BookmarkGroupDto?>> GetBookmarkGroup(int bookmarkGroupId);
[Post("/Create")]
Task<ApiResponse<BookmarkGroupDto?>> CreateBookmarkGroup(string title, string color,
int bookmarkContainerId);
[Delete("/Delete/{bookmarkGroupId}")]
Task<HttpResponseMessage> DeleteBookmarkGroup(int bookmarkGroupId);
}
}

View file

@ -1,15 +1,17 @@
using System.Threading.Tasks;
using Refit;
using System.Net.Http;
namespace Start.Shared.Api {
public interface IBookmarksApi {
[Get("{bookmarkId}")]
Task<BookmarkDto?> GetBookmark(int bookmarkId);
Task<ApiResponse<BookmarkDto?>> GetBookmark(int bookmarkId);
[Post("/Create")]
Task CreateBookmark(string title, string url, string? notes, int bookmarkGroupId);
Task<ApiResponse<BookmarkDto?>> CreateBookmark(string title, string url, string? notes,
int bookmarkGroupId);
[Delete("/Delete/{bookmarkId}")]
Task DeleteBookmark(int bookmarkId);
Task<HttpResponseMessage> DeleteBookmark(int bookmarkId);
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

View file

@ -1,29 +1,36 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Start.Shared {
public class BookmarkGroupDto {
public int BookmarkGroupId { get; set; }
[Required(AllowEmptyStrings = false, ErrorMessage = "Title is required")]
[StringLength(300)]
public string Title { get; set; }
[StringLength(6)]
[Required(AllowEmptyStrings = false, ErrorMessage = "Color is required")]
[StringLength(7)]
public string Color { get; set; }
public int BookmarkContainerId { get; set; }
public IList<BookmarkDto>? Bookmarks { get; set; }
public BookmarkGroupDto(string title, string color) {
public BookmarkGroupDto(string title, string color, int bookmarkContainerId) {
this.Title = title;
this.Color = color;
}
public BookmarkGroupDto(int bookmarkGroupId, string title, string color)
: this(title, color) {
this.BookmarkGroupId = bookmarkGroupId;
this.BookmarkContainerId = bookmarkContainerId;
}
public BookmarkGroupDto(int bookmarkGroupId, string title, string color,
IList<BookmarkDto>? bookmarks) : this(bookmarkGroupId, title, color) {
int bookmarkContainerId)
: this(title, color, bookmarkContainerId) {
this.BookmarkGroupId = bookmarkGroupId;
}
[JsonConstructor]
public BookmarkGroupDto(int bookmarkGroupId, string title, string color,
int bookmarkContainerId, IList<BookmarkDto>? bookmarks)
: this(bookmarkGroupId, title, color, bookmarkContainerId) {
this.Bookmarks = bookmarks;
}
}