C
C#3y ago
bookuha

Minimum need data to create an Entity

My entity:
public class Book : BaseEntity
{
public string Name { get; set; }

public Genres Genres {get; set;}
public string BriefDescription { get; set; }
public string FullDescription { get; set; }

public DateTime OriginallyPublishedAt { get; set; }
public DateTime AppPublishedAt { get; set; }

public ICollection<Author> Authors { get; set; } = new HashSet<Author>();
public ICollection<DownloadableFile> DownloadableFiles { get; set; } = new HashSet<DownloadableFile>();


}
public class Book : BaseEntity
{
public string Name { get; set; }

public Genres Genres {get; set;}
public string BriefDescription { get; set; }
public string FullDescription { get; set; }

public DateTime OriginallyPublishedAt { get; set; }
public DateTime AppPublishedAt { get; set; }

public ICollection<Author> Authors { get; set; } = new HashSet<Author>();
public ICollection<DownloadableFile> DownloadableFiles { get; set; } = new HashSet<DownloadableFile>();


}
My DTO:
public record BookRequest()
{
public long Id { get; set; } // Do I need it here? MSDN has it here
public string Name { get; set; }
public Genres Genres { get; set; }
public string BriefDescription { get; set; }
public string FullDescription { get; set; }
public DateTime OriginallyPublishedAt { get; set; } = new DateTime(1995, 11, 1);
public ICollection<long> AuthorIds { get; set; } = new HashSet<long>();
public ICollection<long> FileIds { get; set; } = new HashSet<long>();
}
public record BookRequest()
{
public long Id { get; set; } // Do I need it here? MSDN has it here
public string Name { get; set; }
public Genres Genres { get; set; }
public string BriefDescription { get; set; }
public string FullDescription { get; set; }
public DateTime OriginallyPublishedAt { get; set; } = new DateTime(1995, 11, 1);
public ICollection<long> AuthorIds { get; set; } = new HashSet<long>();
public ICollection<long> FileIds { get; set; } = new HashSet<long>();
}
The questions are: 1) Do I need that much data just to create a Book? Maybe should I only have "Name" and have the entity populated with PUT/PATCHES later? 2) What could be done better? AuthorIds, FilesIds are obtained by a prior GET request on these resources on the frontend and mapped to the Author and DownloadableFile entites later in a CreateBookHandler Thank you
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?