namespace LibraryApp.Domain.Entities; public class Book { public BookId Id { get; private set; } public BookTitle Title { get; private set; } public BookAuthor Author { get; private set; } public Book(BookTitle title, BookAuthor author) : this(new BookId(string.Empty), title, author) { } public Book(BookId id, BookTitle title, BookAuthor author) { Id = id; Title = title; Author = author; } public Book UpdateTitle(string newTitle) { Title = new (newTitle); return this; } public Book UpdateAuthor(string newAuthor) { Author = new (newAuthor); return this; } } public record BookId : DbId { public BookId(string id) : base(id) {} } public record BookTitle { public string Title { get; init; } public BookTitle(string title) { if(string.IsNullOrWhiteSpace(title)) { throw new ArgumentException("Title cannot be empty."); } Title = title; } } public record BookAuthor { public string Author { get; init; } public BookAuthor(string author) { if(string.IsNullOrWhiteSpace(author)) { throw new ArgumentException("Author cannot be empty."); } Author = author; } }