//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;
            }
        }
Example #2
0
        //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";
            }
        }