//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(FareRestriction fareRestriction)
        {
            //Add LanguageName
            if (fareRestriction.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(fareRestriction.LanguageCode);
                if (language != null)
                {
                    fareRestriction.LanguageName = language.LanguageName;
                }
            }

            ProductRepository productRepository = new ProductRepository();
            Product           product           = new Product();

            product = productRepository.GetProduct(fareRestriction.ProductId);
            if (product != null)
            {
                fareRestriction.ProductName = product.ProductName;
            }

            SupplierRepository supplierRepository = new SupplierRepository();
            Supplier           supplier           = new Supplier();

            supplier = supplierRepository.GetSupplier(fareRestriction.SupplierCode, fareRestriction.ProductId);
            if (supplier != null)
            {
                fareRestriction.SupplierName = supplier.SupplierName;
            }
        }
        //USed for AUthentication??

        /*public List<SystemUserRole> GetSystemUserRoles(string username)
         * {
         *  return (from u in db.spAdmin_SelectSystemUserRoles(username)orderby u.RoleName
         *               select
         *                   new SystemUserRole
         *                   {
         *                       RoleName = u.RoleName.Trim(),
         *                       HierarchyLevelTypeDescription = u.HierarchyLevelTypeDescription.ToString()
         *                   }).ToList();
         * }
         */

        //Used for Authentication??
        //Commented out v3.2.3
        //public static bool ValidateUser(string username)
        //{
        //	var systemUserRepository = new SystemUserRepository();

        //	SystemUser systemUser = systemUserRepository.GetUserByUsername(username);
        //	if (systemUser == null)
        //	{
        //		return false;
        //	}

        //	var authTicket = new FormsAuthenticationTicket(1, username, DateTime.Now,
        //												   DateTime.Now.AddMinutes(30), true, "");

        //	string cookieContents = FormsAuthentication.Encrypt(authTicket);
        //	var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, cookieContents)
        //	{
        //		Expires = authTicket.Expiration,
        //		Path = FormsAuthentication.FormsCookiePath,
        //		Secure = Helpers.Security.IsHttps()
        //	};

        //	if (HttpContext.Current != null)
        //	{
        //			HttpContext.Current.Response.Cookies.Add(cookie);
        //	}
        //	return true;
        //}

        //Add Data From Linked Tables for Display
        public void EditForDisplay(SystemUser systemUser)
        {
            //Add LanguageName
            if (systemUser.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(systemUser.LanguageCode);
                if (language != null)
                {
                    systemUser.LanguageName = language.LanguageName;
                }
            }
            SystemUserLocationRepository systemUserLocationRepository = new SystemUserLocationRepository();
            SystemUserLocation           systemUserLocation           = new SystemUserLocation();

            systemUserLocation = systemUserLocationRepository.GetSystemUserLocation(systemUser.SystemUserGuid);
            if (systemUserLocation != null)
            {
                systemUser.LocationId = systemUserLocation.LocationId;

                HierarchyRepository hierarchyRepository = new HierarchyRepository();
                Location            location            = new Location();
                location = hierarchyRepository.GetLocation(systemUser.LocationId);
                if (location != null)
                {
                    systemUser.LocationName = location.LocationName;
                }
            }
        }
Esempio n. 4
0
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(PolicyAirMissedSavingsThresholdGroupItemLanguage policyAirMissedSavingsThresholdGroupItemLanguage)
        {
            //Add LanguageName
            if (policyAirMissedSavingsThresholdGroupItemLanguage.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(policyAirMissedSavingsThresholdGroupItemLanguage.LanguageCode);
                if (language != null)
                {
                    policyAirMissedSavingsThresholdGroupItemLanguage.LanguageName = language.LanguageName;
                }
            }

            //Add PolicyGroupName
            PolicyAirMissedSavingsThresholdGroupItemRepository policyAirMissedSavingsThresholdGroupItemRepository = new PolicyAirMissedSavingsThresholdGroupItemRepository();
            PolicyAirMissedSavingsThresholdGroupItem           policyAirMissedSavingsThresholdGroupItem           = new PolicyAirMissedSavingsThresholdGroupItem();

            policyAirMissedSavingsThresholdGroupItem = policyAirMissedSavingsThresholdGroupItemRepository.GetPolicyAirMissedSavingsThresholdGroupItem(policyAirMissedSavingsThresholdGroupItemLanguage.PolicyAirMissedSavingsThresholdGroupItemId);


            if (policyAirMissedSavingsThresholdGroupItem != null)
            {
                PolicyGroupRepository policyGroupRepository = new PolicyGroupRepository();
                PolicyGroup           policyGroup           = new PolicyGroup();
                policyGroup = policyGroupRepository.GetGroup(policyAirMissedSavingsThresholdGroupItem.PolicyGroupId);

                //policyAirMissedSavingsThresholdGroupItemRepository.EditItemForDisplay(policyAirMissedSavingsThresholdGroupItem);
                policyAirMissedSavingsThresholdGroupItemLanguage.PolicyGroupName = policyGroup.PolicyGroupName;
                policyAirMissedSavingsThresholdGroupItemLanguage.PolicyGroupId   = policyAirMissedSavingsThresholdGroupItem.PolicyGroupId;
            }
        }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(PolicyAirCabinGroupItemLanguage policyAirCabinGroupItemLanguage)
        {
            //Add LanguageName
            if (policyAirCabinGroupItemLanguage.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(policyAirCabinGroupItemLanguage.LanguageCode);
                if (language != null)
                {
                    policyAirCabinGroupItemLanguage.LanguageName = language.LanguageName;
                }
            }

            //Add PolicyGroup Information
            PolicyAirCabinGroupItemRepository policyAirCabinGroupItemRepository = new PolicyAirCabinGroupItemRepository();
            PolicyAirCabinGroupItem           policyAirCabinGroupItem           = new PolicyAirCabinGroupItem();

            policyAirCabinGroupItem = policyAirCabinGroupItemRepository.GetPolicyAirCabinGroupItem(policyAirCabinGroupItemLanguage.PolicyAirCabinGroupItemId);


            if (policyAirCabinGroupItem != null)
            {
                policyAirCabinGroupItemRepository.EditItemForDisplay(policyAirCabinGroupItem);
                policyAirCabinGroupItemLanguage.PolicyGroupName = policyAirCabinGroupItem.PolicyGroupName;
                policyAirCabinGroupItemLanguage.PolicyGroupId   = policyAirCabinGroupItem.PolicyGroupId;
            }
        }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(ReasonCodeAlternativeDescription reasonCodeAlternativeDescription)
        {
            //Add LanguageName
            if (reasonCodeAlternativeDescription.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(reasonCodeAlternativeDescription.LanguageCode);
                if (language != null)
                {
                    reasonCodeAlternativeDescription.LanguageName = language.LanguageName;
                }
            }

            //Add PolicyGroupName
            ReasonCodeItemRepository reasonCodeItemRepository = new ReasonCodeItemRepository();
            ReasonCodeItem           reasonCodeItem           = new ReasonCodeItem();

            reasonCodeItem = reasonCodeItemRepository.GetItem(reasonCodeAlternativeDescription.ReasonCodeItemId);
            if (reasonCodeItem != null)
            {
                reasonCodeItemRepository.EditItemForDisplay(reasonCodeItem);
                reasonCodeAlternativeDescription.ReasonCodeItemDisplayOrder = reasonCodeItem.DisplayOrder;
            }
        }
Esempio n. 7
0
        //Add Data From Linked Tables for Display
        public void EditGroupForDisplay(MeetingPNROutput group)
        {
            if (group.GDSCode != "")
            {
                GDSRepository GDSRepository = new GDSRepository();
                GDS           GDS           = GDSRepository.GetGDS(group.GDSCode);
                if (GDS != null)
                {
                    group.GDS = GDS;
                }
            }

            if (group.CountryCode != "")
            {
                CountryRepository countryRepository = new CountryRepository();
                Country           country           = countryRepository.GetCountry(group.CountryCode);
                if (country != null)
                {
                    group.Country = country;
                }
            }

            if (group.DefaultLanguageCode != "")
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = languageRepository.GetLanguage(group.DefaultLanguageCode);
                if (language != null)
                {
                    group.Language = language;
                }
            }
        }
Esempio n. 8
0
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(ControlValueLanguage controlValueLanguage)
        {
            //Add LanguageName
            if (controlValueLanguage.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(controlValueLanguage.LanguageCode);
                if (language != null)
                {
                    controlValueLanguage.LanguageName = language.LanguageName;
                }
            }

            //Add PolicyGroupName
            ControlValueRepository controlValueRepository = new ControlValueRepository();
            ControlValue           controlValue           = new ControlValue();

            controlValue = controlValueRepository.GetControlValue(controlValueLanguage.ControlValueId);

            if (controlValue != null)
            {
                controlValueRepository.EditForDisplay(controlValue);
                //controlValueLanguage.ControlValue = controlValue.ControlValue1;
            }
        }
 //Add Data From Linked Tables for Display
 public void EditItemForDisplay(PhraseTranslation phraseTranslation)
 {
     //Add LanguageName
     if (phraseTranslation.LanguageCode != null)
     {
         LanguageRepository languageRepository = new LanguageRepository();
         Language           language           = new Language();
         language = languageRepository.GetLanguage(phraseTranslation.LanguageCode);
         if (language != null)
         {
             phraseTranslation.LanguageName = language.LanguageName;
         }
     }
 }
Esempio n. 10
0
 //Add Data From Linked Tables for Display
 public void EditItemForDisplay(ChatFAQResponseItemLanguage chatFAQResponseItemLanguage)
 {
     //Add LanguageName
     if (chatFAQResponseItemLanguage.LanguageCode != null)
     {
         LanguageRepository languageRepository = new LanguageRepository();
         Language           language           = new Language();
         language = languageRepository.GetLanguage(chatFAQResponseItemLanguage.LanguageCode);
         if (language != null)
         {
             chatFAQResponseItemLanguage.LanguageName = language.LanguageName;
         }
     }
 }
 //Add Data From Linked Tables for Display
 public void EditItemForDisplay(CountryLanguage countryLanguage)
 {
     //Add LanguageName
     if (countryLanguage.LanguageCode != null)
     {
         LanguageRepository languageRepository = new LanguageRepository();
         Language           language           = new Language();
         language = languageRepository.GetLanguage(countryLanguage.LanguageCode);
         if (language != null)
         {
             countryLanguage.LanguageName = language.LanguageName;
         }
     }
 }
 //Add Data From Linked Tables for Display
 public void EditItemForDisplay(FormOfPaymentAdviceMessageGroupItemTranslation formOfPaymentAdviceMessageGroupItemTranslation)
 {
     //Add LanguageName
     if (formOfPaymentAdviceMessageGroupItemTranslation.LanguageCode != null)
     {
         LanguageRepository languageRepository = new LanguageRepository();
         Language           language           = new Language();
         language = languageRepository.GetLanguage(formOfPaymentAdviceMessageGroupItemTranslation.LanguageCode);
         if (language != null)
         {
             formOfPaymentAdviceMessageGroupItemTranslation.LanguageName = language.LanguageName;
         }
     }
 }
Esempio n. 13
0
 public void EditItemForDisplay(MeetingAdviceLanguage meetingAdviceLanguage)
 {
     //Get Language
     if (meetingAdviceLanguage.LanguageCode != null)
     {
         LanguageRepository languageRepository = new LanguageRepository();
         Language           language           = new Language();
         language = languageRepository.GetLanguage(meetingAdviceLanguage.LanguageCode);
         if (language != null)
         {
             meetingAdviceLanguage.Language = language;
         }
     }
 }
Esempio n. 14
0
 //Add Data From Linked Tables for Display
 public void EditItemForDisplay(ReasonCodeProductTypeDescription reasonCodeProductTypeDescription)
 {
     //Add LanguageName
     if (reasonCodeProductTypeDescription.LanguageCode != null)
     {
         LanguageRepository languageRepository = new LanguageRepository();
         Language           language           = new Language();
         language = languageRepository.GetLanguage(reasonCodeProductTypeDescription.LanguageCode);
         if (language != null)
         {
             reasonCodeProductTypeDescription.LanguageName = language.LanguageName;
         }
     }
 }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(FormOfPaymentAdviceMessageGroupItem formOfPaymentAdviceMessageGroupItem)
        {
            //Supplier / Product
            if (formOfPaymentAdviceMessageGroupItem.SupplierCode != null && formOfPaymentAdviceMessageGroupItem.ProductId > 0)
            {
                SupplierRepository supplierRepository = new SupplierRepository();
                Supplier           supplier           = supplierRepository.GetSupplier(formOfPaymentAdviceMessageGroupItem.SupplierCode, formOfPaymentAdviceMessageGroupItem.ProductId);
                if (supplier != null)
                {
                    formOfPaymentAdviceMessageGroupItem.SupplierName = supplier.SupplierName;
                }

                ProductRepository productRepository = new ProductRepository();
                Product           product           = productRepository.GetProduct(formOfPaymentAdviceMessageGroupItem.ProductId);
                if (product != null)
                {
                    formOfPaymentAdviceMessageGroupItem.ProductName = product.ProductName;
                }
            }

            //CountryName
            CountryRepository countryRepository = new CountryRepository();
            Country           country           = countryRepository.GetCountry(formOfPaymentAdviceMessageGroupItem.CountryCode);

            if (country != null)
            {
                formOfPaymentAdviceMessageGroupItem.CountryName = country.CountryName;
            }

            //FormOfPaymentTypeDescription
            FormOfPaymentTypeRepository formOfPaymentTypeRepository = new FormOfPaymentTypeRepository();
            FormOfPaymentType           formOfPaymentType           = formOfPaymentTypeRepository.GetFormOfPaymentType(formOfPaymentAdviceMessageGroupItem.FormofPaymentTypeID);

            if (formOfPaymentType != null)
            {
                formOfPaymentAdviceMessageGroupItem.FormOfPaymentTypeDescription = formOfPaymentType.FormOfPaymentTypeDescription;
            }

            //Set LanguageName to en-gb
            LanguageRepository languageRepository = new LanguageRepository();
            Language           language           = languageRepository.GetLanguage("en-GB");

            if (language != null)
            {
                formOfPaymentAdviceMessageGroupItem.LanguageCode = language.LanguageCode;
                formOfPaymentAdviceMessageGroupItem.LanguageName = language.LanguageName;
            }
        }
Esempio n. 16
0
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(ReasonCodeTravelerDescription reasonCodeTravelerDescription)
        {
            //Add LanguageName
            if (reasonCodeTravelerDescription.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(reasonCodeTravelerDescription.LanguageCode);
                if (language != null)
                {
                    reasonCodeTravelerDescription.LanguageName = language.LanguageName;
                }
            }

            //Add PolicyGroupName
            ReasonCodeItemRepository reasonCodeItemRepository = new ReasonCodeItemRepository();
            ReasonCodeItem           reasonCodeItem           = new ReasonCodeItem();

            reasonCodeItem = reasonCodeItemRepository.GetItem(reasonCodeTravelerDescription.ReasonCodeItemId);
            if (reasonCodeItem != null)
            {
                reasonCodeItemRepository.EditItemForDisplay(reasonCodeItem);
                reasonCodeTravelerDescription.ReasonCodeItemDisplayOrder = reasonCodeItem.DisplayOrder;

                //ReasonCodeProductTypeTravelerDescription
                ReasonCodeProductTypeTravelerDescriptionRepository reasonCodeProductTypeTravelerDescriptionRepository = new ReasonCodeProductTypeTravelerDescriptionRepository();
                ReasonCodeProductTypeTravelerDescription           reasonCodeProductTypeTravelerDescription           = new ReasonCodeProductTypeTravelerDescription();
                reasonCodeProductTypeTravelerDescription = reasonCodeProductTypeTravelerDescriptionRepository.GetItem(
                    "en-GB",
                    reasonCodeItem.ReasonCode,
                    reasonCodeItem.ProductId,
                    reasonCodeItem.ReasonCodeTypeId
                    );

                if (reasonCodeProductTypeTravelerDescription != null)
                {
                    reasonCodeTravelerDescription.ReasonCodeProductTypeTravelerDescription = reasonCodeProductTypeTravelerDescription;
                }
                else
                {
                    reasonCodeTravelerDescription.ReasonCodeProductTypeTravelerDescription = new ReasonCodeProductTypeTravelerDescription();
                }
            }
        }
        //Get one Item from MeetingPNROutput
        public MeetingPNROutputLanguage GetMeetingPNROutputLanguage(int meetingPNROutputId, string languageCode)
        {
            MeetingPNROutputLanguage meetingPNROutputLanguage = new MeetingPNROutputLanguage();

            meetingPNROutputLanguage = db.MeetingPNROutputLanguages.SingleOrDefault(c => c.MeetingPNROutputId == meetingPNROutputId && c.LanguageCode == languageCode);

            if (meetingPNROutputLanguage != null)
            {
                Language           language           = new Language();
                LanguageRepository languageRepository = new LanguageRepository();
                language = languageRepository.GetLanguage(meetingPNROutputLanguage.LanguageCode);
                if (language != null)
                {
                    meetingPNROutputLanguage.Language = language;
                }
            }

            return(meetingPNROutputLanguage);
        }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(ClientSubUnitCreateProfileAdvice clientSubUnitCreateProfileAdvice)
        {
            //Add LanguageName
            if (clientSubUnitCreateProfileAdvice.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(clientSubUnitCreateProfileAdvice.LanguageCode);
                if (language != null)
                {
                    clientSubUnitCreateProfileAdvice.LanguageName = language.LanguageName;
                }
            }

            //Add ClientSubUnitName
            ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository();
            ClientSubUnit           clientSubUnit           = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(clientSubUnitCreateProfileAdvice.ClientSubUnitGuid);
            clientSubUnitCreateProfileAdvice.ClientSubUnitDisplayName = clientSubUnit.ClientSubUnitDisplayName;
        }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(ChatFAQResponseItem chatFAQResponseItem)
        {
            //ChatMessageFAQName
            if (chatFAQResponseItem.ChatMessageFAQId > 0)
            {
                ChatMessageFAQRepository chatMessageFAQRepository = new ChatMessageFAQRepository();
                ChatMessageFAQ           chatMessageFAQ           = chatMessageFAQRepository.GetChatMessageFAQ(chatFAQResponseItem.ChatMessageFAQId);
                if (chatMessageFAQ != null)
                {
                    chatFAQResponseItem.ChatMessageFAQName = chatMessageFAQ.ChatMessageFAQName;
                }
            }

            //Set LanguageName to en-gb
            LanguageRepository languageRepository = new LanguageRepository();
            Language           language           = languageRepository.GetLanguage("en-GB");

            if (language != null)
            {
                chatFAQResponseItem.LanguageCode = language.LanguageCode;
                chatFAQResponseItem.LanguageName = language.LanguageName;
            }
        }
        private void ValidateLines(ref XmlDocument doc, string[] lines, ref List <string> returnMessages)
        {
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);

            doc.AppendChild(dec);
            XmlElement root = doc.CreateElement("BookingChannels");

            doc.AppendChild(root);

            string returnMessage;

            int i = 0;

            //loop through CSV lines
            foreach (string line in lines)
            {
                i++;

                if (i > 1) //ignore first line with titles
                {
                    Regex    csvParser = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");
                    String[] cells     = csvParser.Split(line);

                    //extract the data items from the file
                    string gdsCode = CWTStringHelpers.NullToEmpty(CWTStringHelpers.UnescapeQuotes(cells[0]));                                 //Required
                    string bookingChannelTypeDescription       = CWTStringHelpers.NullToEmpty(CWTStringHelpers.UnescapeQuotes(cells[1]));     //Required
                    string productChannelTypeDescription       = CWTStringHelpers.NullToEmpty(CWTStringHelpers.UnescapeQuotes(cells[2]));     //Required
                    string bookingPseudoCityOrOfficeId         = CWTStringHelpers.NullToEmpty(CWTStringHelpers.UnescapeQuotes(cells[3]));
                    string ticketingPseudoCityOrOfficeId       = CWTStringHelpers.NullToEmpty(CWTStringHelpers.UnescapeQuotes(cells[4]));
                    string desktopUsedTypeDescription          = CWTStringHelpers.NullToEmpty(CWTStringHelpers.UnescapeQuotes(cells[5]));     //Required when Booking Channel = Offline
                    string additionalBookingCommentDescription = CWTStringHelpers.NullToEmpty(CWTStringHelpers.UnescapeQuotes(cells[6]));
                    string languageCode = CWTStringHelpers.NullToEmpty(CWTStringHelpers.UnescapeQuotes(cells[7]));

                    //Build the XML Element for items

                    XmlElement xmlBookingChannelItem = doc.CreateElement("BookingChannelItem");

                    //Validate data

                    /* GDS Code */

                    //Required
                    if (string.IsNullOrEmpty(gdsCode) == true)
                    {
                        returnMessage = "Row " + i + ": GDSCode is missing. Please provide a GDS Code";
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }
                    else
                    {
                        //GDSCode must contain any one value from the GDSCode column of the GDS table
                        GDSRepository gdsRepository = new GDSRepository();
                        GDS           gds           = gdsRepository.GetGDS(gdsCode);
                        if (gds == null)
                        {
                            returnMessage = "Row " + i + ": GDSCode " + gdsCode + " is invalid. Please provide a valid GDS Code";
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }
                    }

                    XmlElement xmlGDSCode = doc.CreateElement("GDSCode");
                    xmlGDSCode.InnerText = gdsCode;
                    xmlBookingChannelItem.AppendChild(xmlGDSCode);

                    /* Booking Channel Type */
                    string bookingChannelTypeId = string.Empty;
                    BookingChannelTypeRepository bookingChannelTypeRepository = new BookingChannelTypeRepository();
                    BookingChannelType           bookingChannelType           = new BookingChannelType();

                    //Required
                    if (string.IsNullOrEmpty(bookingChannelTypeDescription) == true)
                    {
                        returnMessage = "Row " + i + ": Booking Channel  is missing. Please provide a Booking Channel";
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }
                    else
                    {
                        //BookingChannelTypeDescription must contain any one value from the BookingChannelTypeDescription column of the BookingChannelType table
                        bookingChannelType = bookingChannelTypeRepository.GetBookingChannelTypeByDescription(bookingChannelTypeDescription);

                        if (bookingChannelType == null)
                        {
                            returnMessage = "Row " + i + ": BookingChannelTypeDescription " + bookingChannelTypeDescription + " is invalid. Please provide a valid BookingChannelType Code";
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }
                        else
                        {
                            bookingChannelTypeId = bookingChannelType.BookingChannelTypeId.ToString();
                        }
                    }

                    XmlElement xmlBookingChannelTypeId = doc.CreateElement("BookingChannelTypeId");
                    xmlBookingChannelTypeId.InnerText = bookingChannelTypeId;
                    xmlBookingChannelItem.AppendChild(xmlBookingChannelTypeId);

                    /* Product Channel Type */
                    string productChannelTypeId = string.Empty;

                    ProductChannelTypeRepository productChannelTypeRepository = new ProductChannelTypeRepository();
                    ProductChannelType           productChannelType           = new ProductChannelType();

                    //Required
                    if (string.IsNullOrEmpty(productChannelTypeDescription) == true)
                    {
                        returnMessage = "Row " + i + ": Product Channel is missing. Please provide a Product Channel";
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }
                    else
                    {
                        //ProductChannelTypeDescription must contain any one value from the ProductChannelTypeDescription column of the ProductChannelType table
                        productChannelType = productChannelTypeRepository.GetProductChannelTypeByDescription(productChannelTypeDescription);
                        if (productChannelType == null)
                        {
                            returnMessage = "Row " + i + ": ProductChannelTypeDescription " + productChannelTypeDescription + " is invalid. Please provide a valid ProductChannelType Code";
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }
                        else
                        {
                            productChannelTypeId = productChannelType.ProductChannelTypeId.ToString();
                        }
                    }

                    XmlElement xmlProductChannelTypeId = doc.CreateElement("ProductChannelTypeId");
                    xmlProductChannelTypeId.InnerText = productChannelTypeId;
                    xmlBookingChannelItem.AppendChild(xmlProductChannelTypeId);

                    //ProductChannelTypeId and BookingChannelTypeID must be present in the ProductChannelType table
                    if (bookingChannelType != null && bookingChannelType.BookingChannelTypeId > 0 && productChannelType != null && productChannelType.ProductChannelTypeId > 0)
                    {
                        ProductChannelType productChannelBookingChannelType = productChannelTypeRepository.GetProductChannelTypeBookingChannelType(bookingChannelType.BookingChannelTypeId, productChannelType.ProductChannelTypeId);
                        if (productChannelBookingChannelType == null)
                        {
                            returnMessage = "Row " + i + ": Product Channel and Booking Channel combination is invalid. Please provide a valid combination";
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }
                    }

                    /* DesktopUsedTypeDescription */
                    string desktopUsedTypeId = string.Empty;

                    //Required if BookingChannelTypeDescription is Offline
                    if (string.IsNullOrEmpty(desktopUsedTypeDescription) == true && bookingChannelTypeDescription.ToLower() == "offline")
                    {
                        returnMessage = "Row " + i + ": Desktop Used is required when Booking Channel is Offline. Please provide a valid Desktop Used or change Booking Channel";
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }
                    else if (!string.IsNullOrEmpty(desktopUsedTypeDescription))
                    {
                        //DesktopUsed must contain any one value from the DesktopUsedTypeDescription column of the DesktopUsedType table
                        DesktopUsedTypeRepository desktopUsedTypeRepository = new DesktopUsedTypeRepository();
                        DesktopUsedType           desktopUsedType           = desktopUsedTypeRepository.GetDesktopUsedTypeByDescription(desktopUsedTypeDescription);
                        if (desktopUsedType == null)
                        {
                            returnMessage = "Row " + i + ": Desktop Used  " + desktopUsedTypeDescription + " is invalid. Please provide a valid Desktop Used";
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }
                        else
                        {
                            desktopUsedTypeId = desktopUsedType.DesktopUsedTypeId.ToString();
                        }
                    }

                    XmlElement xmlDesktopUsedTypeId = doc.CreateElement("DesktopUsedTypeId");
                    xmlDesktopUsedTypeId.InnerText = desktopUsedTypeId;
                    xmlBookingChannelItem.AppendChild(xmlDesktopUsedTypeId);

                    /* BookingPseudoCityOrOfficeId  */

                    int validBookingPseudoCityOrOfficeIdCount = db.ValidPseudoCityOrOfficeIds.Where(x => x.PseudoCityOrOfficeId == bookingPseudoCityOrOfficeId).Count();
                    if (!string.IsNullOrEmpty(bookingPseudoCityOrOfficeId) && validBookingPseudoCityOrOfficeIdCount == 0)
                    {
                        returnMessage = "Row " + i + ": BookingPseudoCityOrOfficeId " + bookingPseudoCityOrOfficeId + " is invalid. Please provide a valid BookingPseudoCityOrOfficeId";
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }

                    /* Trim if is not null */

                    if (!string.IsNullOrEmpty(bookingPseudoCityOrOfficeId))
                    {
                        bookingPseudoCityOrOfficeId = bookingPseudoCityOrOfficeId.Trim();
                    }

                    XmlElement xmlBookingPseudoCityOrOfficeId = doc.CreateElement("BookingPseudoCityOrOfficeId");
                    xmlBookingPseudoCityOrOfficeId.InnerText = bookingPseudoCityOrOfficeId;
                    xmlBookingChannelItem.AppendChild(xmlBookingPseudoCityOrOfficeId);

                    /* TicketingPseudoCityOrOfficeId   */

                    int validTicketingPseudoCityOrOfficeIdCount = db.ValidPseudoCityOrOfficeIds.Where(x => x.PseudoCityOrOfficeId == ticketingPseudoCityOrOfficeId).Count();
                    if (!string.IsNullOrEmpty(ticketingPseudoCityOrOfficeId) && validTicketingPseudoCityOrOfficeIdCount == 0)
                    {
                        returnMessage = "Row " + i + ": TicketingPseudoCityOrOfficeId " + ticketingPseudoCityOrOfficeId + " is invalid. Please provide a valid TicketingPseudoCityOrOfficeId";
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }

                    /* Trim if is not null */

                    if (!string.IsNullOrEmpty(ticketingPseudoCityOrOfficeId))
                    {
                        ticketingPseudoCityOrOfficeId = ticketingPseudoCityOrOfficeId.Trim();
                    }

                    XmlElement xmlTicketingPseudoCityOrOfficeId = doc.CreateElement("TicketingPseudoCityOrOfficeId");
                    xmlTicketingPseudoCityOrOfficeId.InnerText = ticketingPseudoCityOrOfficeId;
                    xmlBookingChannelItem.AppendChild(xmlTicketingPseudoCityOrOfficeId);

                    /* AdditionalBookingComment  */

                    if (!string.IsNullOrEmpty(additionalBookingCommentDescription))
                    {
                        //AdditionalBookingComment is freeform text and will allow up to 1500 alphanumeric and allowable special characters.
                        if (additionalBookingCommentDescription.Length > 1500)
                        {
                            returnMessage = "Row " + i + ": AdditionalBookingComment contains more than 1500 characters. Please provide a valid AdditionalBookingComment";
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }

                        //Allowable special characters are: space, dash, underscore, right and left parentheses, period, apostrophe (O’Reily), ampersand and accented characters.
                        string additionalBookingCommentPattern = @"^[À-ÿ\w\s\-\(\)\.\&\'\’_]+$";
                        if (!Regex.IsMatch(additionalBookingCommentDescription, additionalBookingCommentPattern, RegexOptions.IgnoreCase))
                        {
                            returnMessage = "Row " + i + ": AdditionalBookingComment contains invalid special characters. Please provide a valid AdditionalBookingComment";
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }
                    }

                    XmlElement xmlAdditionalBookingCommentDescription = doc.CreateElement("AdditionalBookingCommentDescription");
                    xmlAdditionalBookingCommentDescription.InnerText = additionalBookingCommentDescription;
                    xmlBookingChannelItem.AppendChild(xmlAdditionalBookingCommentDescription);

                    /* Language Code */

                    //Where the AdditionalBookingComment value exists, then the LanguageCode column must contain a LanguageCode value,
                    if (!string.IsNullOrEmpty(additionalBookingCommentDescription) && (languageCode == null || string.IsNullOrEmpty(languageCode)))
                    {
                        returnMessage = "Row " + i + ": AdditionalBookingComment provided, LanguageCode is mandatory. Please provide a valid LanguageCode";
                        if (!returnMessages.Contains(returnMessage))
                        {
                            returnMessages.Add(returnMessage);
                        }
                    }

                    //LanguageCode must contain any one value from the LanguageCode column of the Language table
                    if (!string.IsNullOrEmpty(languageCode))
                    {
                        LanguageRepository languageRepository = new LanguageRepository();
                        Language           language           = languageRepository.GetLanguage(languageCode);
                        if (language == null)
                        {
                            returnMessage = "Row " + i + ": LanguageCode " + languageCode + " is invalid. Please provide a valid Language Code";
                            if (!returnMessages.Contains(returnMessage))
                            {
                                returnMessages.Add(returnMessage);
                            }
                        }
                    }

                    XmlElement xmlLanguageCode = doc.CreateElement("LanguageCode");
                    xmlLanguageCode.InnerText = languageCode;
                    xmlBookingChannelItem.AppendChild(xmlLanguageCode);

                    //Attach the XML Element for an item to the Document
                    root.AppendChild(xmlBookingChannelItem);
                }
            }

            if (i == 0)
            {
                returnMessage = "There is no data in the file";
                returnMessages.Add(returnMessage);
            }
        }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(PNROutputGroupLanguage pnrOutputGroupLanguage)
        {
            //Add LanguageName
            if (pnrOutputGroupLanguage.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(pnrOutputGroupLanguage.LanguageCode);
                if (language != null)
                {
                    pnrOutputGroupLanguage.LanguageName = language.LanguageName;
                }
            }

            //Add PolicyGroup Information
            PNROutputGroupRepository pnrOutputGroupRepository = new PNROutputGroupRepository();
            PNROutputGroup           pnrOutputGroup           = new PNROutputGroup();

            pnrOutputGroup = pnrOutputGroupRepository.GetGroup(pnrOutputGroupLanguage.PNROutputGroupId);
            if (pnrOutputGroup != null)
            {
                pnrOutputGroupLanguage.PNROutputGroupName = pnrOutputGroup.PNROutputGroupName;
            }

            //Format XML
            if (pnrOutputGroupLanguage.PNROutputGroupXML != null)
            {
                XDocument xDoc           = new XDocument(pnrOutputGroupLanguage.PNROutputGroupXML);
                string    baseRemarkType = xDoc.Root.Name.ToString();
                var       items          = xDoc.Element(baseRemarkType).Elements("item");
                int       counter        = 0;

                PNROutputGroupXMLDoc pnrOutputGroupXMLDoc = new PNROutputGroupXMLDoc();
                pnrOutputGroupXMLDoc.DocumentRoot = baseRemarkType;

                foreach (var item in items)
                {
                    PNROutputGroupXMLItem pnrOutputGroupXMLItem = new PNROutputGroupXMLItem();
                    pnrOutputGroupXMLItem.ItemNumber = counter;
                    string valueText = (string)item.Value;
                    if (valueText != null)
                    {
                        pnrOutputGroupXMLItem.Value = item.Value;
                    }
                    string remarkTypeAttribute = (string)item.Attribute("remarktype");
                    if (remarkTypeAttribute != null)
                    {
                        pnrOutputGroupXMLItem.RemarkType = item.Attribute("remarktype").Value;
                    }
                    string bindAttribute = (string)item.Attribute("bind");
                    if (bindAttribute != null)
                    {
                        pnrOutputGroupXMLItem.Bind = item.Attribute("bind").Value;
                    }
                    string qualifierAttribute = (string)item.Attribute("qualifier");
                    if (qualifierAttribute != null)
                    {
                        pnrOutputGroupXMLItem.Qualifier = item.Attribute("qualifier").Value;
                    }
                    string sequenceAttribute = (string)item.Attribute("sequence");
                    if (sequenceAttribute != null)
                    {
                        pnrOutputGroupXMLItem.Sequence = item.Attribute("sequence").Value;
                    }
                    string updateTypeAttribute = (string)item.Attribute("updatetype");
                    if (updateTypeAttribute != null)
                    {
                        pnrOutputGroupXMLItem.UpdateType = item.Attribute("updatetype").Value;
                    }
                    string groupIdAttribute = (string)item.Attribute("groupid");
                    if (groupIdAttribute != null)
                    {
                        pnrOutputGroupXMLItem.GroupId = item.Attribute("groupid").Value;
                    }

                    pnrOutputGroupXMLDoc.AddPNROutputGroupXMLItem(pnrOutputGroupXMLItem);
                    counter++;
                }
                pnrOutputGroupLanguage.PNROutputGroupXMLDOM = pnrOutputGroupXMLDoc;
            }
        }
        //get a single Node from the XML field
        public PNROutputGroupXMLItem GetPNROutputGroupXMLItem(int node, PNROutputGroupLanguage pnrOutputGroupLanguage)
        {
            XDocument             xDoc                  = new XDocument(pnrOutputGroupLanguage.PNROutputGroupXML);
            string                baseRemarkType        = xDoc.Root.Name.ToString();
            var                   items                 = xDoc.Element(baseRemarkType).Elements("item");
            var                   item                  = xDoc.Element(baseRemarkType).Elements("item").ElementAt(node);
            PNROutputGroupXMLItem pnrOutputGroupXMLItem = new PNROutputGroupXMLItem();

            //Add LanguageName
            if (pnrOutputGroupLanguage.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(pnrOutputGroupLanguage.LanguageCode);
                if (language != null)
                {
                    pnrOutputGroupXMLItem.Language = language;
                }
            }

            //Add PolicyGroup Information
            PNROutputGroupRepository pnrOutputGroupRepository = new PNROutputGroupRepository();
            PNROutputGroup           pnrOutputGroup           = new PNROutputGroup();

            pnrOutputGroup = pnrOutputGroupRepository.GetGroup(pnrOutputGroupLanguage.PNROutputGroupId);
            if (pnrOutputGroup != null)
            {
                pnrOutputGroupXMLItem.PNROutputGroup = pnrOutputGroup;
            }
            //we need to keep version number, no need for other itmes
            PNROutputGroupLanguage pnrOutputGroupLanguage2 = new PNROutputGroupLanguage();

            pnrOutputGroupLanguage2.VersionNumber        = pnrOutputGroupLanguage.VersionNumber;
            pnrOutputGroupXMLItem.PNROutputGroupLanguage = pnrOutputGroupLanguage2;

            pnrOutputGroupXMLItem.Language.LanguageCode           = pnrOutputGroupLanguage.LanguageCode;
            pnrOutputGroupXMLItem.PNROutputGroup.PNROutputGroupId = pnrOutputGroupLanguage.PNROutputGroupId;


            string valueText = (string)item.Value;

            if (valueText != null)
            {
                pnrOutputGroupXMLItem.Value = item.Value;
            }
            string remarkTypeAttribute = (string)item.Attribute("remarktype");

            if (remarkTypeAttribute != null)
            {
                pnrOutputGroupXMLItem.RemarkType = item.Attribute("remarktype").Value;
            }
            string bindAttribute = (string)item.Attribute("bind");

            if (bindAttribute != null)
            {
                pnrOutputGroupXMLItem.Bind = item.Attribute("bind").Value;
            }
            string qualifierAttribute = (string)item.Attribute("qualifier");

            if (qualifierAttribute != null)
            {
                pnrOutputGroupXMLItem.Qualifier = item.Attribute("qualifier").Value;
            }
            string sequenceAttribute = (string)item.Attribute("sequence");

            if (sequenceAttribute != null)
            {
                pnrOutputGroupXMLItem.Sequence = item.Attribute("sequence").Value;
            }
            string updateTypeAttribute = (string)item.Attribute("updatetype");

            if (updateTypeAttribute != null)
            {
                pnrOutputGroupXMLItem.UpdateType = item.Attribute("updatetype").Value;
            }
            string groupIdAttribute = (string)item.Attribute("groupid");

            if (groupIdAttribute != null)
            {
                pnrOutputGroupXMLItem.GroupId = item.Attribute("groupid").Value;
            }
            return(pnrOutputGroupXMLItem);
        }