refactor(domain): introduce ReservationFactory for reconstitution
Replace the Reconstitute static method on Reservation with a dedicated ReservationFactory class. The reconstitution constructor is now internal, restricting direct instantiation to within the domain assembly while keeping the factory as the explicit entry point for rehydrating from storage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,12 +13,7 @@ public class Reservation : Entity
|
||||
public ReservationStatus Status { get; private set; }
|
||||
public DateTime CreatedAt { get; private set; }
|
||||
|
||||
public static Reservation Reconstitute(
|
||||
Guid id, Guid workplaceId, string employeeEmail, string employeeName,
|
||||
DateOnly date, ReservationStatus status, DateTime createdAt) =>
|
||||
new(id, workplaceId, employeeEmail, employeeName, date, status, createdAt);
|
||||
|
||||
private Reservation(
|
||||
internal Reservation(
|
||||
Guid id, Guid workplaceId, string employeeEmail, string employeeName,
|
||||
DateOnly date, ReservationStatus status, DateTime createdAt) : base(id)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Randall.Domain.Reservations;
|
||||
|
||||
public static class ReservationFactory
|
||||
{
|
||||
public static Reservation Reconstitute(
|
||||
Guid id, Guid workplaceId, string employeeEmail, string employeeName,
|
||||
DateOnly date, ReservationStatus status, DateTime createdAt) =>
|
||||
new(id, workplaceId, employeeEmail, employeeName, date, status, createdAt);
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace Randall.Infrastructure.Persistence.Mappers;
|
||||
public static class ReservationMapper
|
||||
{
|
||||
public static Reservation ToDomain(ReservationRecord record) =>
|
||||
Reservation.Reconstitute(
|
||||
ReservationFactory.Reconstitute(
|
||||
record.Id,
|
||||
record.WorkplaceId,
|
||||
record.EmployeeEmail,
|
||||
|
||||
Reference in New Issue
Block a user