Create shared DTO classes

This commit is contained in:
Neil Brommer 2021-11-13 20:27:59 -08:00
parent 00136bc11b
commit b52610e126
3 changed files with 81 additions and 0 deletions

View file

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Start.Shared {
public class BookmarkContainerDto {
public int BookmarkContainerId { get; set; }
[StringLength(300)]
public string Title { get; set; }
public IList<BookmarkGroupDto>? BookmarkGroups { get; set; }
public BookmarkContainerDto(string title) {
this.Title = title;
}
public BookmarkContainerDto(int bookmarkContainerId, string title) : this(title) {
this.BookmarkContainerId = bookmarkContainerId;
}
public BookmarkContainerDto(int bookmarkContainerId, string title,
IList<BookmarkGroupDto> bookmarkGroups) : this(bookmarkContainerId, title) {
this.BookmarkGroups = bookmarkGroups;
}
}
}

View file

@ -0,0 +1,25 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace Start.Shared {
public class BookmarkDto {
public int BookmarkId { get; set; }
[StringLength(300)]
public string Title { get; set; }
[StringLength(2000)]
public string Url { get; set; }
[StringLength(5000)]
public string? Notes { get; set; }
public BookmarkDto(string title, string url, string? notes) {
this.Title = title;
this.Url = url;
this.Notes = notes;
}
public BookmarkDto(int bookmarkId, string title, string url, string? notes)
: this(title, url, notes) {
this.BookmarkId = bookmarkId;
}
}
}

View file

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Start.Shared {
public class BookmarkGroupDto {
public int BookmarkGroupId { get; set; }
[StringLength(300)]
public string Title { get; set; }
[StringLength(6)]
public string Color { get; set; }
public IList<BookmarkDto>? Bookmarks { get; set; }
public BookmarkGroupDto(string title, string color) {
this.Title = title;
this.Color = color;
}
public BookmarkGroupDto(int bookmarkGroupId, string title, string color)
: this(title, color) {
this.BookmarkGroupId = bookmarkGroupId;
}
public BookmarkGroupDto(int bookmarkGroupId, string title, string color,
IList<BookmarkDto> bookmarks) : this(bookmarkGroupId, title, color) {
this.Bookmarks = bookmarks;
}
}
}