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); }
public JsonResult Create(CustomerDemographicDetailView vm) { CreateCustomerDemographicRequest request = new CreateCustomerDemographicRequest(); request.CustomerDesc = vm.CustomerDesc; CreateCustomerDemographicResponse response = _customerDemographicService.CreateCustomerDemographic(request); return(Json(response)); }