BlazorStart/Start/Shared/BookmarkGroupDto.cs

38 lines
1.2 KiB
C#
Raw Normal View History

2021-12-05 23:50:48 +00:00
using System.Collections.Generic;
2021-11-14 04:27:59 +00:00
using System.ComponentModel.DataAnnotations;
2021-12-05 23:50:48 +00:00
using System.Text.Json.Serialization;
2021-11-14 04:27:59 +00:00
namespace Start.Shared {
public class BookmarkGroupDto {
public int BookmarkGroupId { get; set; }
2021-12-05 23:50:48 +00:00
[Required(AllowEmptyStrings = false, ErrorMessage = "Title is required")]
2021-11-14 04:27:59 +00:00
[StringLength(300)]
public string Title { get; set; }
2021-12-05 23:50:48 +00:00
[Required(AllowEmptyStrings = false, ErrorMessage = "Color is required")]
[StringLength(7)]
2021-11-14 04:27:59 +00:00
public string Color { get; set; }
2021-12-05 23:50:48 +00:00
public int BookmarkContainerId { get; set; }
2021-11-14 04:27:59 +00:00
public IList<BookmarkDto>? Bookmarks { get; set; }
2021-12-05 23:50:48 +00:00
public BookmarkGroupDto(string title, string color, int bookmarkContainerId) {
2021-11-14 04:27:59 +00:00
this.Title = title;
this.Color = color;
2021-12-05 23:50:48 +00:00
this.BookmarkContainerId = bookmarkContainerId;
2021-11-14 04:27:59 +00:00
}
2021-12-05 23:50:48 +00:00
public BookmarkGroupDto(int bookmarkGroupId, string title, string color,
int bookmarkContainerId)
: this(title, color, bookmarkContainerId) {
2021-11-14 04:27:59 +00:00
this.BookmarkGroupId = bookmarkGroupId;
}
2021-12-05 23:50:48 +00:00
[JsonConstructor]
2021-11-14 04:27:59 +00:00
public BookmarkGroupDto(int bookmarkGroupId, string title, string color,
2021-12-05 23:50:48 +00:00
int bookmarkContainerId, IList<BookmarkDto>? bookmarks)
: this(bookmarkGroupId, title, color, bookmarkContainerId) {
2021-11-14 04:27:59 +00:00
this.Bookmarks = bookmarks;
}
}
}