public static string CheckForDRFraud(DistributorOrderingProfile distributor, string zipCode)
        {
            string errorResxKey = string.Empty;
            var    fraudStatus = DRFraudStatusType.None;
            bool   isBlocked, isSponsorBlocked, isDsFound;

            isBlocked = isSponsorBlocked = isDsFound = false;

            using (var proxy = ServiceClientProvider.GetOrderServiceProxy())
            {
                try
                {
                    if (distributor != null && distributor.FraudStatus == null)
                    {
                        using (var proxyDs = ServiceClientProvider.GetDistributorServiceProxy())
                        {
                            var requestV01 = new GetBasicDistributorRequest_V01
                            {
                                DistributorID = distributor.Id
                            };

                            var circuitBreaker =
                                CircuitBreakerFactory.GetFactory().GetCircuitBreaker <GetBasicDistributorResponse_V01>();
                            var responseV01 =
                                circuitBreaker.Execute(() => proxyDs.GetBasicDistributor(new GetBasicDistributorRequest(requestV01))).GetBasicDistributorResult as
                                GetBasicDistributorResponse_V01;

                            if (responseV01 != null && responseV01.Status == ServiceResponseStatusType.Success)
                            {
                                if (responseV01.Distributor != null)
                                {
                                    isBlocked        = responseV01.Distributor.DRFraudStatusFlags.IsDistributorblocked;
                                    isSponsorBlocked = responseV01.Distributor.DRFraudStatusFlags.IsSponsorBlocked;
                                    isDsFound        = true;
                                }
                            }
                        }
                    }
                    else if (distributor != null && distributor.FraudStatus != null)
                    {
                        isBlocked        = distributor.FraudStatus.IsDistributorblocked;
                        isSponsorBlocked = distributor.FraudStatus.IsSponsorBlocked;
                        isDsFound        = true;
                    }

                    if (isDsFound)
                    {
                        var request = new GetDRFraudStatusRequest_V01();
                        request.DistributorID        = distributor.Id;
                        request.CountryCode          = distributor.CurrentLoggedInCountry;
                        request.PostalCode           = zipCode;
                        request.DistributorIsBlocked = isBlocked;
                        request.SponsorIsBlocked     = isSponsorBlocked;

                        var response =
                            proxy.GetDRFraudStatus(new GetDRFraudStatusRequest(request)).GetDRFraudStatusResult as GetDRFraudStatusResponse_V01;
                        if (response.Status == ServiceProvider.OrderSvc.ServiceResponseStatusType.Success)
                        {
                            fraudStatus = response.FraudStatus;
                        }
                    }
                    else
                    {
                        LoggerHelper.Exception("System.Exception", new Exception(
                                                   string.Format(
                                                       "Error retrieving DS DRFraudStatusFlags from Cache and Distributor service for: DS:{0} - Country:{1}",
                                                       distributor.Id, distributor.CurrentLoggedInCountry)));
                        fraudStatus = DRFraudStatusType.None;
                    }
                }
                catch (Exception ex)
                {
                    LoggerHelper.Exception("System.Exception", new Exception(
                                               string.Format(
                                                   "Error retrieving DRFraud Status from Order service for: DS:{0} - Country:{1}, {2}",
                                                   distributor.Id, distributor.CurrentLoggedInCountry, ex)));
                    fraudStatus = DRFraudStatusType.None;
                }
            }

            if (fraudStatus == DRFraudStatusType.DistributorIsBlocked)
            {
                errorResxKey = "BlockedDS";
            }
            else if (fraudStatus == DRFraudStatusType.PostalCodeIsBlocked)
            {
                errorResxKey = "BlockedZip";
            }

            return(errorResxKey);
        }
        public static DRFraudStatusType CheckForDRFraud(string distributorID, string countryCode, string zipCode)
        {
            var fraudStatus = DRFraudStatusType.None;

            string CacheKey = string.Format("{0}_{1}", "DSFraud", countryCode);
            Dictionary <string, List <string> > blockedPostalCodes = HttpRuntime.Cache[CacheKey] as Dictionary <string, List <string> >;

            DistributorOrderingProfile distributorOrderingProfile = GetProfile(distributorID, countryCode);

            if (blockedPostalCodes == null)
            {
                using (var proxy = ServiceClientProvider.GetOrderServiceProxy())
                {
                    try
                    {
                        var request = new GetDRFraudStatusRequest_V01();
                        request.DistributorID = distributorID;
                        request.CountryCode   = countryCode;
                        request.PostalCode    = zipCode;

                        request.DistributorIsBlocked = distributorOrderingProfile.IsDistributorBlocked;
                        request.SponsorIsBlocked     = distributorOrderingProfile.IsSponsorBlocked;

                        var response =
                            proxy.GetDRFraudStatus(new GetDRFraudStatusRequest(request)).GetDRFraudStatusResult as GetDRFraudStatusResponse_V01;
                        if (response.Status == ServiceProvider.OrderSvc.ServiceResponseStatusType.Success)
                        {
                            fraudStatus        = response.FraudStatus;
                            blockedPostalCodes = response.BlockedPostCodes;
                        }
                        HttpRuntime.Cache[CacheKey] = response.BlockedPostCodes != null ? response.BlockedPostCodes : new Dictionary <string, List <string> > {
                        };
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Exception("System.Exception", new Exception(
                                                   string.Format(
                                                       "Error retrieving DRFraud Status from Order service for: DS:{0} - Country:{1}, {2}",
                                                       distributorID, countryCode, ex)));
                        fraudStatus = DRFraudStatusType.None;
                    }
                }
            }
            if (distributorOrderingProfile.IsDistributorBlocked && blockedPostalCodes != null)
            {
                if (blockedPostalCodes.ContainsKey(countryCode) && blockedPostalCodes[countryCode].Contains(zipCode))
                {
                    return(DRFraudStatusType.PostalCodeIsBlocked);
                }
            }

            //if (fraudStatus == DRFraudStatusType.DistributorIsBlocked)
            //{
            //    errorResxKey = "BlockedDS";
            //}
            //else if (fraudStatus == DRFraudStatusType.PostalCodeIsBlocked)
            //{
            //    errorResxKey = "BlockedZip";
            //}

            return(fraudStatus);
        }