public ModifyCustomerDemographicResponse ModifyCustomerDemographic(ModifyCustomerDemographicRequest request)
        {
            ModifyCustomerDemographicResponse response = new ModifyCustomerDemographicResponse();

            CustomerDemographic customerDemographic = _customerDemographicRepository
                                                      .FindBy(request.CustomerTypeID);

            customerDemographic.Id           = request.CustomerTypeID;
            customerDemographic.CustomerDesc = request.CustomerDesc;
            customerDemographic.Customers    = request.Customers.ConvertToCustomers();


            if (customerDemographic.GetBrokenRules().Count() > 0)
            {
                response.Errors = customerDemographic.GetBrokenRules().ToList();
            }
            else
            {
                try {
                    _customerDemographicRepository.Save(customerDemographic);
                    _uow.Commit();
                    response.Errors = new List <BusinessRule>();
                } catch (Exception ex)
                {
                    response.Errors = new List <BusinessRule>();
                    response.Errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message));
                }
            }


            return(response);
        }
        public CreateCustomerDemographicResponse CreateCustomerDemographic(CreateCustomerDemographicRequest request)
        {
            CreateCustomerDemographicResponse response = new CreateCustomerDemographicResponse();
            CustomerDemographic customerDemographic    = new CustomerDemographic();

            customerDemographic.CustomerDesc = request.CustomerDesc;
            customerDemographic.Customers    = request.Customers.ConvertToCustomers();

            if (customerDemographic.GetBrokenRules().Count() > 0)
            {
                response.Errors = customerDemographic.GetBrokenRules().ToList();
            }
            else
            {
                try {
                    _customerDemographicRepository.Add(customerDemographic);
                    _uow.Commit();
                    response.Errors = new List <BusinessRule>();
                } catch (Exception ex)
                {
                    List <BusinessRule> errors = new List <BusinessRule>();
                    do
                    {
                        errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message));
                        ex = ex.InnerException;
                    } while (ex != null);

                    response.Errors = errors;
                }
            }

            return(response);
        }