public static Scheme CheckDsLevelType(string distributorID, string countryCode)
        {
            //string DsLevel =new LevelGroupType();
            //List<DistributorTraining_V01> trainings = new List<DistributorTraining_V01>();
            using (var proxy = ServiceClientProvider.GetDistributorServiceProxy())
            {
                try
                {
                    var response = proxy.GetBasicDistributor(new GetBasicDistributorRequest(
                                                                 new GetBasicDistributorRequest_V01()
                    {
                        DistributorID = distributorID,
                        CountryCode   = countryCode,
                        RequiresTin   = false
                    })).GetBasicDistributorResult as GetBasicDistributorResponse_V01;

                    if (response.Status == ServiceResponseStatusType.Success && response.Distributor != null)
                    {
                        return(response.Distributor.Scheme);
                    }
                }
                catch (Exception ex)
                {
                    LoggerHelper.Warn(
                        string.Format("MyHerbalife3.Ordering.Providers.DistributorOrderingProfileProvider - distributorId: {0} - Exception: {1}",
                                      distributorID, ex.Message));
                }
            }

            return(Scheme.Distributor);
        }
        public static void GetHAPSettings(DistributorOrderingProfile distributor)
        {
            if (!distributor.HAPExpiryDateSpecified || distributor.HAPExpiryDate == null)
            {
                using (var proxy = ServiceClientProvider.GetDistributorServiceProxy())
                {
                    try
                    {
                        var response = proxy.GetBasicDistributor(new GetBasicDistributorRequest(
                                                                     new GetBasicDistributorRequest_V01()
                        {
                            DistributorID = distributor.Id,
                            CountryCode   = distributor.CurrentLoggedInCountry,
                            RequiresTin   = false
                        })).GetBasicDistributorResult as GetBasicDistributorResponse_V01;

                        if (response.Status == ServiceResponseStatusType.Success && response.Distributor != null)
                        {
                            distributor.HAPExpiryDateSpecified = response.Distributor.HAPExpiryDateFieldSpecified;
                            distributor.HAPExpiryDate          = response.Distributor.HAPExpiryDateField;
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Warn(
                            string.Format("MyHerbalife3.Ordering.Providers.DistributorOrderingProfileProvider.GetHAPSettings - distributorId: {0} - country: {1} - Exception: {2}",
                                          distributor.Id, distributor.CurrentLoggedInCountry, ex.Message));
                    }
                }
            }
        }
        public static GetBasicDistributorResponse_V01 GetDistributorProfileforEmail(string distributorID, string countryCode)
        {
            var response = new GetBasicDistributorResponse_V01();

            using (var proxy = ServiceClientProvider.GetDistributorServiceProxy())
            {
                try
                {
                    response = proxy.GetBasicDistributor(new GetBasicDistributorRequest(
                                                             new GetBasicDistributorRequest_V01()
                    {
                        DistributorID = distributorID,
                        CountryCode   = countryCode,
                        RequiresTin   = false
                    })).GetBasicDistributorResult as GetBasicDistributorResponse_V01;

                    if (response.Status == ServiceResponseStatusType.Success && response.Distributor != null)
                    {
                    }
                }
                catch (Exception ex)
                {
                    LoggerHelper.Warn(
                        string.Format("MyHerbalife3.Ordering.Providers.DistributorOrderingProfileProvider - distributorId: {0} - country: {1} - Exception: {2}",
                                      distributorID, countryCode, ex.Message));
                }
            }

            return(response);
        }
        public static bool ClearDistributorCache(string distributorID, string type)
        {
            bool IsCleared = false;

            try
            {
                var proxy = ServiceClientProvider.GetDistributorServiceProxy();

                IsCleared = proxy.ClearCache(new ServiceProvider.DistributorSvc.ClearCacheRequest(distributorID, type)).ClearCacheResult;
            }
            catch (Exception ex)
            {
                LoggerHelper.Warn(
                    string.Format("MyHerbalife3.Ordering.Providers.ClearDistributorCache - distributorId: {0} - type: {1} - Exception: {2}",
                                  distributorID, type, ex.Message));
            }


            return(IsCleared);
        }
        /// <summary>
        ///     Create payment information from the payment info control
        /// </summary>
        /// <returns>The payment information object</returns>
        protected override PaymentInformation createPaymentInfoFromControl()
        {
            PaymentInformation paymentInfo = null;

            if (PaymentID > 0)
            {
                paymentInfo = base.paymentInfos.Find(p => p.ID == PaymentID);
                if (null == paymentInfo)
                {
                    paymentInfo = new PaymentInformation();
                }
            }
            else
            {
                paymentInfo = new PaymentInformation();
            }
            ///TODO: Confirm name to be broken down
            paymentInfo.CardHolder = new Name_V01()
            {
                First = FirstName, Last = LastName, Middle = MiddleInnitial
            };
            if (!base.IsMasked(CardNumber))
            {
                paymentInfo.CardNumber = CardNumber;
            }
            paymentInfo.CardType  = CardType;
            paymentInfo.Created   = DateTime.Now;
            paymentInfo.Alias     = NickName;
            paymentInfo.IsPrimary = IsPrimary;

            try
            {
                paymentInfo.Expiration = convertExpDateToDatetimeFormat(paymentInfo.CardType);
            }

            catch (Exception ex)
            {
                LoggerHelper.Warn(ex.ToString());
            }

            paymentInfo.ID = PaymentID;
            Address_V01 billingAddress = new Address_V01();

            if (rblBillingAddress.SelectedIndex == 0)
            {
                var shippingAddress = getShippingAddress().Address;
                billingAddress.Line1 = shippingAddress.Line1;
                billingAddress.Line2 = shippingAddress.Line2;
                billingAddress.Line3 = shippingAddress.Line3;
                billingAddress.Line4 = shippingAddress.Line4;
                billingAddress.City  = shippingAddress.City;
                billingAddress.StateProvinceTerritory = shippingAddress.StateProvinceTerritory;
                billingAddress.PostalCode             = shippingAddress.PostalCode;
                billingAddress.Country = this.CountryCode;
            }
            else
            {
                var line1 = string.Concat(txtStreetAddress.Text.Trim(), " ", txtStreetAddress2.Text).Trim();
                var line4 = string.Concat(txtStreetAddress.Text.Trim(), "%%%", txtStreetAddress2.Text).Trim();
                billingAddress.Line1 = line1.Length <= 50 ? line1 : line1.Substring(0, 50);
                billingAddress.Line2 = txtNeighborhood.Text.Trim();
                billingAddress.Line3 = txtNumber.Text.Trim();
                billingAddress.Line4 = line4.Length <= 50 ? line4 : line4.Substring(0, 50);
                billingAddress.City  = txtCity.Text.Trim();
                billingAddress.StateProvinceTerritory = txtState.Text.Trim();
                billingAddress.PostalCode             = txtZip.Text;
                billingAddress.Country = this.CountryCode;
            }
            paymentInfo.BillingAddress = billingAddress;

            return(paymentInfo);
        }