عنوان:

‫اعتبارسنجی Domain Model‎


نویسنده: سالار ربال
تاریخ: ۱۳۹۸/۰۵/۲۸ ۱۲:۳
آدرس: www.dntips.ir

BC scope validation implementation 

public interface ICustomerUniquenessChecker
{
    bool IsUnique(Customer customer);
}
public Customer(string email, string name, ICustomerUniquenessChecker customerUniquenessChecker)
{
    this.Email = email;
    this.Name = name;

    var isUnique = customerUniquenessChecker.IsUnique(this);
    if (!isUnique)
    {
        throw new BusinessRuleValidationException("Customer with this email already exists.");
    }

    this.AddDomainEvent(new CustomerRegisteredEvent(this));
}




مشاهده مطلب اصلی

نظرات