示例#1
0
        public void Create(Business business, string password)
        {
            if (String.IsNullOrEmpty(password))
            {
                throw new ValidationException("Password is rquired");
            }
            if (_repository.CheckIfExist(business.Email, business.CompanyName))
            {
                throw new ValidationException("Email or company name already in use");
            }

            if (!_addressValidator.Validate(business.Address).Result)
            {
                throw new ValidationException("Address is bad formated or missing data", business.Address);
            }

            if (business.PhoneNumber.Length != 9)
            {
                throw new ValidationException("Phone number is not valid", business.PhoneNumber);
            }

            try
            {
                _accountManager.CreateUser(business, password, _repository);
            }
            catch (ValidationException ex)
            {
                throw new ValidationException(ex.Message, ex.Arguments);
            }
        }