private DMOffice DataValidation(DMOffice office) { office.IsValid = true; var customerObject = MapperHelper.CreateDataObjectFromObject(office); foreach (var item in customerObject) { switch (item.Key) { case "PhysicalCountry": var physicalCountry = _countryService.GetCountryByCountryName(office.PhysicalCountry); if (physicalCountry == null) { office.IsPartialValid = false; office.Reason += "Physical country not found"; } break; case "PhysicalState": var physicalState = _stateService.GetStateByStateName(office.PhysicalState); if (physicalState == null) { office.IsPartialValid = false; office.Reason += "Physical state not found"; } break; case "MailingCountry": var mailingCountry = _countryService.GetCountryByCountryName(office.MailingCountry); if (mailingCountry == null) { office.IsPartialValid = false; office.Reason += "Mailing country not found"; } else { office.MailingCountryGuid = mailingCountry.CountryId; } break; case "MailingState": var mailingState = _stateService.GetStateByStateName(office.MailingState); if (mailingState == null) { office.IsPartialValid = false; office.Reason += "Mailing state not found"; } else { office.MailingStateGuid = mailingState.StateId; } break; case "PhysicalCity": if (string.IsNullOrEmpty(office.PhysicalCity)) { office.IsPartialValid = false; office.Reason = "PhysicalCity is empty"; } break; case "PhysicalAddress": if (string.IsNullOrEmpty(office.PhysicalAddress)) { office.IsPartialValid = false; office.Reason = "PhysicalAddress is empty"; } break; case "": if (string.IsNullOrEmpty(office.Phone)) { office.IsPartialValid = false; office.Reason = "Phone is empty"; } break; } } return(office); }
private DMCustomer DataValidation(DMCustomer customer) { customer.IsValid = true; var customerObject = MapperHelper.CreateDataObjectFromObject(customer); foreach (var item in customerObject) { switch (item.Key) { case "State": if (!string.IsNullOrEmpty(customer.State)) { var state = _stateService.GetStateByStateName(customer.State); if (state == null) { customer.Reason += "Invalid state."; customer.IsValid = false; customer.ImportStatus = ImportStatus.Fail.ToString(); } else { customer.StateId = state.StateId; } } break; case "Country": if (!string.IsNullOrEmpty(customer.Country)) { var country = _countryService.GetCountryByCountryName(customer.Country); if (country == null) { customer.Reason += "Invalid Country."; customer.IsValid = false; customer.ImportStatus = ImportStatus.Fail.ToString(); } else { customer.CountryId = country.CountryId; } } break; case "CustomerType": if (!string.IsNullOrWhiteSpace(customer.CustomerType)) { var customerType = _customerTypeService.GetCustomerTypeByName(customer.CustomerType); if (customerType == Guid.Empty) { customer.Reason += "Invalid customer type."; customer.IsValid = false; customer.ImportStatus = ImportStatus.Fail.ToString(); } else { customer.CustomerTypeGuid = customerType; } } break; } } return(customer); }
private DMRegion GetRegion(DMRegion region) { var regionObject = MapperHelper.CreateDataObjectFromObject(region); return(region); }