45 lines
922 B
C#
45 lines
922 B
C#
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;
|
|
}
|
|
}
|