예제 #1
0
        //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;
            }
        }
        //puts codes into correct properties
        public void EditPolicyRouting(PolicyRouting policyRouting)
        {
            string fromCodeType = policyRouting.FromCodeType;
            string fromCode     = policyRouting.FromCode;
            string toCodeType   = policyRouting.ToCodeType;
            string toCode       = policyRouting.ToCode;

            #region polpulate from/to
            if (fromCodeType == "GlobalRegion")
            {
                policyRouting.FromTravelPortCode      = null;
                policyRouting.FromTraverlPortTypeId   = null;
                policyRouting.FromCityCode            = null;
                policyRouting.FromCountryCode         = null;
                policyRouting.FromGlobalSubRegionCode = null;
                policyRouting.FromGlobalRegionCode    = fromCode;
                policyRouting.FromGlobalFlag          = false;
            }
            else if (fromCodeType == "GlobalSubRegion")
            {
                policyRouting.FromTravelPortCode      = null;
                policyRouting.FromTraverlPortTypeId   = null;
                policyRouting.FromCityCode            = null;
                policyRouting.FromCountryCode         = null;
                policyRouting.FromGlobalSubRegionCode = fromCode;
                policyRouting.FromGlobalRegionCode    = null;
                policyRouting.FromGlobalFlag          = false;
            }
            else if (fromCodeType == "Country")
            {
                policyRouting.FromTravelPortCode      = null;
                policyRouting.FromTraverlPortTypeId   = null;
                policyRouting.FromCityCode            = null;
                policyRouting.FromCountryCode         = fromCode;
                policyRouting.FromGlobalSubRegionCode = null;
                policyRouting.FromGlobalRegionCode    = null;
                policyRouting.FromGlobalFlag          = false;
            }
            else if (fromCodeType == "City")
            {
                policyRouting.FromTravelPortCode      = null;
                policyRouting.FromTraverlPortTypeId   = null;
                policyRouting.FromCityCode            = fromCode;
                policyRouting.FromCountryCode         = null;
                policyRouting.FromGlobalSubRegionCode = null;
                policyRouting.FromGlobalRegionCode    = null;
                policyRouting.FromGlobalFlag          = false;
            }
            else if (fromCodeType == "TravelPort")
            {
                policyRouting.FromTravelPortCode      = fromCode;
                policyRouting.FromTraverlPortTypeId   = null;
                policyRouting.FromCityCode            = null;
                policyRouting.FromCountryCode         = null;
                policyRouting.FromGlobalSubRegionCode = null;
                policyRouting.FromGlobalRegionCode    = null;
                policyRouting.FromGlobalFlag          = false;
            }
            else if (fromCodeType == "TravelPortType")
            {
                TravelPortTypeRepository travelPortTypeRepository = new TravelPortTypeRepository();
                TravelPortType           travelPortType           = new TravelPortType();
                travelPortType = travelPortTypeRepository.GetTravelPortTypeByDescription(policyRouting.FromCode);

                policyRouting.FromTravelPortCode      = null;
                policyRouting.FromTraverlPortTypeId   = travelPortType.TravelPortTypeId;
                policyRouting.FromCityCode            = null;
                policyRouting.FromCountryCode         = null;
                policyRouting.FromGlobalSubRegionCode = null;
                policyRouting.FromGlobalRegionCode    = null;
                policyRouting.FromGlobalFlag          = false;
            }
            else if (fromCodeType == "Global")
            {
                policyRouting.FromTravelPortCode      = null;
                policyRouting.FromTraverlPortTypeId   = null;
                policyRouting.FromCityCode            = null;
                policyRouting.FromCountryCode         = null;
                policyRouting.FromGlobalSubRegionCode = null;
                policyRouting.FromGlobalRegionCode    = null;
                policyRouting.FromGlobalFlag          = true;
            }
            if (toCodeType == "GlobalRegion")
            {
                policyRouting.ToTravelPortCode      = null;
                policyRouting.ToTravelPortTypeId    = null;
                policyRouting.ToCityCode            = null;
                policyRouting.ToCountryCode         = null;
                policyRouting.ToGlobalSubRegionCode = null;
                policyRouting.ToGlobalRegionCode    = toCode;
                policyRouting.ToGlobalFlag          = false;
            }
            else if (toCodeType == "GlobalSubRegion")
            {
                policyRouting.ToTravelPortCode      = null;
                policyRouting.ToTravelPortTypeId    = null;
                policyRouting.ToCityCode            = null;
                policyRouting.ToCountryCode         = null;
                policyRouting.ToGlobalSubRegionCode = toCode;
                policyRouting.ToGlobalRegionCode    = null;
                policyRouting.ToGlobalFlag          = false;
            }
            else if (toCodeType == "Country")
            {
                policyRouting.ToTravelPortCode      = null;
                policyRouting.ToTravelPortTypeId    = null;
                policyRouting.ToCityCode            = null;
                policyRouting.ToCountryCode         = toCode;
                policyRouting.ToGlobalSubRegionCode = null;
                policyRouting.ToGlobalRegionCode    = null;
                policyRouting.ToGlobalFlag          = false;
            }
            else if (toCodeType == "City")
            {
                policyRouting.ToTravelPortCode      = null;
                policyRouting.ToTravelPortTypeId    = null;
                policyRouting.ToCityCode            = toCode;
                policyRouting.ToCountryCode         = null;
                policyRouting.ToGlobalSubRegionCode = null;
                policyRouting.ToGlobalRegionCode    = null;
                policyRouting.ToGlobalFlag          = false;
            }
            else if (toCodeType == "TravelPort")
            {
                policyRouting.ToTravelPortCode      = toCode;
                policyRouting.ToTravelPortTypeId    = null;
                policyRouting.ToCityCode            = null;
                policyRouting.ToCountryCode         = null;
                policyRouting.ToGlobalSubRegionCode = null;
                policyRouting.ToGlobalRegionCode    = null;
                policyRouting.ToGlobalFlag          = false;
            }
            else if (toCodeType == "TravelPortType")
            {
                TravelPortTypeRepository travelPortTypeRepository = new TravelPortTypeRepository();
                TravelPortType           travelPortType           = new TravelPortType();
                travelPortType = travelPortTypeRepository.GetTravelPortTypeByDescription(policyRouting.ToCode);

                policyRouting.ToTravelPortCode      = null;
                policyRouting.ToTravelPortTypeId    = travelPortType.TravelPortTypeId.ToString();
                policyRouting.ToCityCode            = null;
                policyRouting.ToCountryCode         = null;
                policyRouting.ToGlobalSubRegionCode = null;
                policyRouting.ToGlobalRegionCode    = null;
                policyRouting.ToGlobalFlag          = false;
            }
            else if (toCodeType == "Global")
            {
                policyRouting.ToTravelPortCode      = null;
                policyRouting.ToTravelPortTypeId    = null;
                policyRouting.ToCityCode            = null;
                policyRouting.ToCountryCode         = null;
                policyRouting.ToGlobalSubRegionCode = null;
                policyRouting.ToGlobalRegionCode    = null;
                policyRouting.ToGlobalFlag          = true;
            }
            #endregion
        }
예제 #4
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";
            }
        }
        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);
        }