Updated the domain model with entities, repos and domain services. Looks good. I think I addressed all the user stories however if I fell short we'll revise as needed.

This commit was merged in pull request #6.
This commit is contained in:
2026-04-10 17:43:58 +05:00
parent 57040bc656
commit 8eb8cd4fbf
14 changed files with 621 additions and 6 deletions
+65
View File
@@ -0,0 +1,65 @@
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;
}
}