Esempio n. 1
0
        protected void BindGrid()
        {
            CountryCollection       countryCollection       = CountryManager.GetAllCountries();
            PaymentMethodCollection paymentMethodCollection = PaymentMethodManager.GetAllPaymentMethods(null, false);

            if (countryCollection.Count == 0)
            {
                lblMessage.Text = GetLocaleResourceString("Admin.PaymentMethodsFilterControl.NoCountryDefined");
            }
            if (paymentMethodCollection.Count == 0)
            {
                lblMessage.Text = GetLocaleResourceString("Admin.PaymentMethodsFilterControl.NoPaymentMethodDefined");
            }

            List <PaymentMethodCountryMappingHelperClass> dt = new List <PaymentMethodCountryMappingHelperClass>();

            foreach (Country country in countryCollection)
            {
                PaymentMethodCountryMappingHelperClass map1 = new PaymentMethodCountryMappingHelperClass();
                map1.CountryId   = country.CountryId;
                map1.CountryName = country.Name;
                map1.Restrict    = new Dictionary <int, bool>();

                foreach (PaymentMethod paymentMethod in paymentMethodCollection)
                {
                    map1.Restrict.Add(paymentMethod.PaymentMethodId, PaymentMethodManager.DoesPaymentMethodCountryMappingExist(paymentMethod.PaymentMethodId, country.CountryId));
                }

                dt.Add(map1);
            }

            gvPaymentMethodCountryMap.DataSource = dt;
            gvPaymentMethodCountryMap.DataBind();
        }
Esempio n. 2
0
        public void SaveInfo()
        {
            var paymentMethods = PaymentMethodManager.GetAllPaymentMethods(null, false);

            foreach (GridViewRow row in gvPaymentMethodCountryMap.Rows)
            {
                foreach (PaymentMethod paymentMethod in paymentMethods)
                {
                    CheckBox    cbRestrict  = row.FindControl(String.Format("cbRestrict_{0}", paymentMethod.PaymentMethodId)) as CheckBox;
                    HiddenField hfCountryId = row.FindControl(String.Format("hfCountryId_{0}", paymentMethod.PaymentMethodId)) as HiddenField;
                    if (cbRestrict == null || hfCountryId == null)
                    {
                        return;
                    }

                    int countryId = Int32.Parse(hfCountryId.Value);

                    if (cbRestrict.Checked)
                    {
                        PaymentMethodManager.CreatePaymentMethodCountryMapping(paymentMethod.PaymentMethodId, countryId);
                    }
                    else
                    {
                        if (PaymentMethodManager.DoesPaymentMethodCountryMappingExist(paymentMethod.PaymentMethodId, countryId))
                        {
                            PaymentMethodManager.DeletePaymentMethodCountryMapping(paymentMethod.PaymentMethodId, countryId);
                        }
                    }
                }
            }
        }