//Add Data From Linked Tables for Display public void EditForDisplay(TravelPort travelPort) { CountryRepository countryRepository = new CountryRepository(); Country country = new Country(); country = countryRepository.GetCountry(travelPort.CountryCode); if (country != null) { travelPort.CountryName = country.CountryName; } CityRepository cityRepository = new CityRepository(); City city = new City(); city = cityRepository.GetCity(travelPort.CityCode); if (city != null) { travelPort.CityName = city.Name; } TravelPortTypeRepository travelPortTypeRepository = new TravelPortTypeRepository(); TravelPortType travelPortType = new TravelPortType(); travelPortType = travelPortTypeRepository.GetTravelPortType(travelPort.TravelPortTypeId); if (travelPortType != null) { travelPort.TravelPortTypeDescription = travelPortType.TravelPortTypeDescription; } travelPort.LatitudeDecimal = Convert.ToDecimal(travelPort.Latitude); travelPort.LongitudeDecimal = Convert.ToDecimal(travelPort.Longitude); }
//Add Data From Linked Tables for Display public void EditForDisplay(TravelPortLanguage travelPortLanguage) { //Add TravelPortTypeDescription TravelPortTypeRepository travelPortTypeRepository = new TravelPortTypeRepository(); TravelPortType travelPortType = new TravelPortType(); travelPortType = travelPortTypeRepository.GetTravelPortType(travelPortLanguage.TravelPortTypeId); if (travelPortType != null) { travelPortLanguage.TravelPortTypeDescription = travelPortType.TravelPortTypeDescription; } //Add LanguageName if (travelPortLanguage.LanguageCode != null) { LanguageRepository languageRepository = new LanguageRepository(); Language language = new Language(); language = languageRepository.GetLanguage(travelPortLanguage.LanguageCode); if (language != null) { travelPortLanguage.LanguageName = language.LanguageName; } } //Add TravelPortCodeTravelPortName (name of original) TravelPortRepository travelPortRepository = new TravelPortRepository(); TravelPort travelPort = new TravelPort(); travelPort = travelPortRepository.GetTravelPort(travelPortLanguage.TravelPortCode); if (travelPort != null) { travelPortLanguage.TravelPortCodeTravelPortName = travelPort.TravelportName; } }
//Add Data From Linked Tables for Display public void EditForDisplay(PolicyLocation policyLocation) { if (policyLocation.TravelPortCode != null) { TravelPortRepository travelPortRepository = new TravelPortRepository(); TravelPort travelPort = new TravelPort(); travelPort = travelPortRepository.GetTravelPort(policyLocation.TravelPortCode); if (travelPort != null) { policyLocation.TravelPortName = travelPort.TravelportName; policyLocation.LocationCode = travelPort.TravelPortCode; policyLocation.LocationName = travelPort.TravelportName; } } if (policyLocation.TravelPortTypeId != null) { int travelPortTypeId = (int)policyLocation.TravelPortTypeId; TravelPortTypeRepository travelPortTypeRepository = new TravelPortTypeRepository(); TravelPortType travelPortType = new TravelPortType(); travelPortType = travelPortTypeRepository.GetTravelPortType(travelPortTypeId); if (travelPortType != null) { policyLocation.TravelPortType = travelPortType.TravelPortTypeDescription; } } HierarchyRepository hierarchyRepository = new HierarchyRepository(); string globalRegionCode = policyLocation.GlobalRegionCode; if (globalRegionCode != null) { GlobalRegion globalRegion = new GlobalRegion(); globalRegion = hierarchyRepository.GetGlobalRegion(globalRegionCode); policyLocation.LocationCode = globalRegion.GlobalRegionCode; policyLocation.LocationName = globalRegion.GlobalRegionName; } string globalSubRegionCode = policyLocation.GlobalSubRegionCode; if (globalSubRegionCode != null) { GlobalSubRegion globalSubRegion = new GlobalSubRegion(); globalSubRegion = hierarchyRepository.GetGlobalSubRegion(globalSubRegionCode); policyLocation.LocationCode = globalSubRegion.GlobalSubRegionCode; policyLocation.LocationName = globalSubRegion.GlobalSubRegionName; } string countryCode = policyLocation.CountryCode; if (countryCode != null) { Country country = new Country(); country = hierarchyRepository.GetCountry(countryCode); policyLocation.LocationCode = country.CountryCode; policyLocation.LocationName = country.CountryName; } string cityCode = policyLocation.CityCode; if (cityCode != null) { CityRepository cityRepository = new CityRepository(); City city = new City(); city = cityRepository.GetCity(cityCode); policyLocation.LocationCode = city.CityCode; policyLocation.LocationName = city.Name; } if (policyLocation.GlobalFlag) { policyLocation.LocationName = "Global"; policyLocation.LocationCode = "Global"; } }
public PolicyRouting GetPolicyRouting(int policyRoutingId) { PolicyRouting policyRouting = db.PolicyRoutings.SingleOrDefault(c => c.PolicyRoutingId == policyRoutingId); if (policyRouting.FromCode == null && policyRouting.FromGlobalFlag == false) { policyRouting.FromCode = (policyRouting.FromGlobalRegionCode ?? policyRouting.FromGlobalSubRegionCode ?? policyRouting.FromCountryCode ?? policyRouting.FromCityCode ?? policyRouting.FromTravelPortCode ?? policyRouting.FromTraverlPortTypeId.ToString() ?? "" ); } if (policyRouting.ToCode == null && policyRouting.ToGlobalFlag == false) { policyRouting.ToCode = (policyRouting.ToGlobalRegionCode ?? policyRouting.ToGlobalSubRegionCode ?? policyRouting.ToCountryCode ?? policyRouting.ToCityCode ?? policyRouting.ToTravelPortCode ?? (policyRouting.ToTravelPortTypeId != null ? policyRouting.ToTravelPortTypeId.ToString() : "") ); } if (policyRouting.ToGlobalRegionCode != null) { policyRouting.ToCodeType = "GlobalRegion"; } else if (policyRouting.ToGlobalSubRegionCode != null) { policyRouting.ToCodeType = "GlobalSubRegion"; } else if (policyRouting.ToCountryCode != null) { policyRouting.ToCodeType = "Country"; } else if (policyRouting.ToCityCode != null) { policyRouting.ToCodeType = "City"; } else if (policyRouting.ToTravelPortCode != null) { policyRouting.ToCodeType = "TravelPort"; } else if (policyRouting.ToTravelPortTypeId != null) { policyRouting.ToCodeType = "TravelPortType"; TravelPortTypeRepository travelPortTypeRepository = new TravelPortTypeRepository(); TravelPortType travelPortType = new TravelPortType(); travelPortType = travelPortTypeRepository.GetTravelPortType(Convert.ToInt32(policyRouting.ToCode)); policyRouting.ToCode = travelPortType.TravelPortTypeDescription; } else { policyRouting.ToCodeType = "Global"; } if (policyRouting.FromGlobalRegionCode != null) { policyRouting.FromCodeType = "GlobalRegion"; } else if (policyRouting.FromGlobalSubRegionCode != null) { policyRouting.FromCodeType = "GlobalSubRegion"; } else if (policyRouting.FromCountryCode != null) { policyRouting.FromCodeType = "Country"; } else if (policyRouting.FromCityCode != null) { policyRouting.FromCodeType = "City"; } else if (policyRouting.FromTravelPortCode != null) { policyRouting.FromCodeType = "TravelPort"; } else if (policyRouting.FromTraverlPortTypeId != null) { policyRouting.FromCodeType = "TravelPortType"; TravelPortTypeRepository travelPortTypeRepository = new TravelPortTypeRepository(); TravelPortType travelPortType = new TravelPortType(); travelPortType = travelPortTypeRepository.GetTravelPortType(Convert.ToInt32(policyRouting.FromCode)); policyRouting.FromCode = travelPortType.TravelPortTypeDescription; } else { policyRouting.FromCodeType = "Global"; } policyRouting.Name = Regex.Replace(policyRouting.Name, @"[^\w\s\-()*]", "-"); return(policyRouting); }