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:
@@ -0,0 +1,44 @@
|
||||
namespace LibraryApp.Domain.Entities;
|
||||
|
||||
public class Shelf
|
||||
{
|
||||
public ShelfId Id { get; private set; }
|
||||
public ShelfName Name { get; private set; }
|
||||
public DateTime? LastCountedAt { get; private set; }
|
||||
|
||||
public Shelf(ShelfName name)
|
||||
: this(new ShelfId(string.Empty), name, null)
|
||||
{ }
|
||||
|
||||
public Shelf(ShelfId id, ShelfName name, DateTime? lastCountedAt)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
LastCountedAt = lastCountedAt;
|
||||
}
|
||||
|
||||
public Shelf RecordCount()
|
||||
{
|
||||
LastCountedAt = DateTime.UtcNow;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public record ShelfId : DbId
|
||||
{
|
||||
public ShelfId(string id) : base(id) {}
|
||||
}
|
||||
|
||||
public record ShelfName
|
||||
{
|
||||
public string Name { get; init; }
|
||||
|
||||
public ShelfName(string name)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
throw new ArgumentException("Shelf name cannot be empty.");
|
||||
}
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user