コード例 #1
0
ファイル: User.cs プロジェクト: kashanix/butterfly
        public static User Create(
            string email,
            string name,
            decimal monthlySalary,
            decimal monthlyExpense,
            IUserUniqueValidation userUniqueChecker)
        {
            if (string.IsNullOrEmpty(email))
            {
                throw new DomainValidationException("email can not be empty");
            }

            Validate(new UserExpenseMustBeZeroRule(monthlyExpense));
            Validate(new UserSalaryMustBeZeroRule(monthlyExpense));
            Validate(new UserEmailMustBeUniqueRule(userUniqueChecker, email));

            return(new User(email, name, monthlySalary, monthlyExpense));
        }
コード例 #2
0
 public UserEmailMustBeUniqueRule(IUserUniqueValidation userUniquenessChecker, string email)
 {
     _userUniquenessChecker = userUniquenessChecker;
     _email = email;
 }