Пример #1
0
        public string CreateCustomer(string applicationReference, Customer customer)
        {
            Check.If(applicationReference).IsNotNullOrEmpty();
            Check.If(customer).IsNotNull();

            if (!string.IsNullOrEmpty(customer.CustomerReference))
            {
                return null;
            }

            //check if someone is trying to add a master tenant when we already have one
            if (customer.IsMasterTenant())
            {
                var customers = _customerRepository.GetCustomersForApplication(applicationReference);

                if (customers.FirstOrDefault(c => c.RoleType == RoleType.MasterTenant) != null)
                    return null;
            }

            var result = _customerRepository.CreateCustomerForApplication(applicationReference,
                customer.CreateReference(_referenceGenerator));

            UpdateApplicationStatus(applicationReference, customer);

            return result ? customer.CustomerReference : null;
        }
Пример #2
0
 private void UpdateApplicationStatus(string applicationReference, Customer customer)
 {
     if (customer.IsMasterTenant())
         _customerRepository.UpdateApplicationStatus(applicationReference, customer.Status);
 }