public void Initialize(int customerID)
        {
            var upline = Exigo.OData().Customers
                .Where(c => c.CustomerID == customerID)
                .Select(c => new
                {
                    c.EnrollerID,
                    c.SponsorID
                }).FirstOrDefault();

            if (upline == null) return;

            if(upline.EnrollerID != null) this.Enroller = Exigo.GetCustomer((int)upline.EnrollerID);
            if (upline.SponsorID != null) this.Sponsor = Exigo.GetCustomer((int)upline.SponsorID);
        }
        /// <summary>
        /// This method determines if all the eligiblity requirements are met for this reward.
        /// </summary>
        protected override bool EligibilityRequirements(Customer customer, string siteType)
        {
            var newSA = false;

            if (siteType != "backOffice")
            {
                return(false);
            }
            if (customer.CustomerTypeID != CustomerTypes.IndependentStyleAmbassador)
            {
                return(false);
            }

            if (customer.Date1.HasValue && customer.Date1.Value > new DateTime(2016, 08, 08, 2, 0, 0))
            {
                return(false);
            }

            if (customer.Date1.HasValue && customer.Date1.Value >= new DateTime(2016, 06, 01, 0, 0, 0) &&
                customer.Date1.Value <= new DateTime(2016, 08, 08, 2, 0, 0))
            {
                newSA = true;
            }

            using (var context = Exigo.Sql())
            {
                try {
                    var sqlProcedure     = string.Format(@"GetSumOfVolume12 {0},{1}", customer.CustomerID, PeriodTypes.Monthly);
                    var eligiblePRV      = newSA ? 0 : context.Query <decimal>(sqlProcedure).FirstOrDefault();
                    var reward           = GetActiveNewProductsLaunchRewards(customer, eligiblePRV);
                    var creditsRemaining = CreditsRemaining(customer.CustomerID, reward);
                    if (reward == null || creditsRemaining <= 0)
                    {
                        return(false);
                    }
                    EligibleReward   = reward;
                    AvailableCredits = creditsRemaining;
                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
        public SetCustomerSiteRequest(Customer customer)
        {
            CustomerID = customer.CustomerID;
            WebAlias = customer.LoginName;
            FirstName = customer.FirstName;
            LastName = customer.LastName;
            Company = customer.Company;

            Email = customer.Email;
            Phone = customer.PrimaryPhone;
            Phone2 = customer.SecondaryPhone;
            Fax = customer.Fax;

            if (customer.MainAddress != null)
            {
                Address1 = customer.MainAddress.Address1;
                Address2 = customer.MainAddress.Address2;
                City = customer.MainAddress.City;
                State = customer.MainAddress.State;
                Zip = customer.MainAddress.Zip;
                Country = customer.MainAddress.Country;
            }
        }
Exemple #4
0
 public bool IsEligible(ExigoService.Customer customer, string siteType)
 {
     throw new NotImplementedException();
 }
        public CreateCustomerRequest(Customer customer)
        {
            CustomerType        = customer.CustomerTypeID;
            CustomerStatus      = customer.CustomerStatusID;
            DefaultWarehouseID  = customer.DefaultWarehouseID;
            LanguageID          = customer.LanguageID;
            EntryDate           = customer.CreatedDate;
            BirthDate           = customer.BirthDate;

            FirstName           = customer.FirstName;
            LastName            = customer.LastName;
            Email               = customer.Email;
            Phone               = customer.PrimaryPhone;
            Phone2              = customer.SecondaryPhone;
            MobilePhone         = customer.MobilePhone;
            Fax                 = customer.Fax;

            if (customer.MainAddress != null)
            {
                MainAddress1 = customer.MainAddress.Address1;
                MainAddress2 = customer.MainAddress.Address2;
                MainCity     = customer.MainAddress.City;
                MainState    = customer.MainAddress.State;
                MainZip      = customer.MainAddress.Zip;
                MainCountry  = customer.MainAddress.Country;
            }

            if (customer.MailingAddress != null)
            {
                MailAddress1 = customer.MailingAddress.Address1;
                MailAddress2 = customer.MailingAddress.Address2;
                MailCity     = customer.MailingAddress.City;
                MailState    = customer.MailingAddress.State;
                MailZip      = customer.MailingAddress.Zip;
                MailCountry  = customer.MailingAddress.Country;
            }

            if (customer.OtherAddress != null)
            {
                OtherAddress1 = customer.OtherAddress.Address1;
                OtherAddress2 = customer.OtherAddress.Address2;
                OtherCity     = customer.OtherAddress.City;
                OtherState    = customer.OtherAddress.State;
                OtherZip      = customer.OtherAddress.Zip;
                OtherCountry  = customer.OtherAddress.Country;
            }

            TaxID         = customer.TaxID;
            PayableToName = customer.PayableToName;
            PayableType   = Exigo.GetPayableType(customer.PayableTypeID);

            LoginName = customer.LoginName;
            LoginPassword = customer.Password;

            if (customer.EnrollerID != null)
            {
                InsertEnrollerTree = true;
                EnrollerID = (int)customer.EnrollerID;
            }

            if (customer.SponsorID != null)
            {
                InsertUnilevelTree = true;
                SponsorID = (int)customer.SponsorID;
            }

            if(customer.IsOptedIn)
            {
                SubscribeToBroadcasts  = customer.IsOptedIn;
                SubscribeFromIPAddress = GlobalUtilities.GetClientIP();

            }

            Field1  = customer.Field1;
            Field2  = customer.Field2;
            Field3  = customer.Field3;
            Field4  = customer.Field4;
            Field5  = customer.Field5;
            Field6  = customer.Field6;
            Field7  = customer.Field7;
            Field8  = customer.Field8;
            Field9  = customer.Field9;
            Field10 = customer.Field10;
            Field11 = customer.Field11;
            Field12 = customer.Field12;
            Field13 = customer.Field13;
            Field14 = customer.Field14;
            Field15 = customer.Field15;

            Date1 = customer.Date1;
            Date2 = customer.Date2;
            Date3 = customer.Date3;
            Date4 = customer.Date4;
            Date5 = customer.Date5;
        }
        /// <summary>
        /// This method returns the New Products Launch % off rewards that are currently active
        /// </summary>
        private Api.ExigoOData.Rewards.NewProductsLaunchReward GetActiveNewProductsLaunchRewards(Customer customer, decimal eligiblePRV)
        {
            //var context = Exigo.CreateODataContext<RewardsContext>(GlobalSettings.Exigo.Api.SandboxID);
            var customerStartDate = SAStartDate(customer);

            //var newSAReward = context.NewProductsLaunchRewards.Where(c => c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now && c.Credits == 998 && c.PRVThresholdMin == 0).FirstOrDefault();
            Common.Api.ExigoOData.Rewards.NewProductsLaunchReward newSAReward = null;

            try
            {
                using (var context = Exigo.Sql())
                {
                    var SqlProcedure = string.Format("newSAReward '{0}',{1},{2}", DateTime.Now, 998, 0);
                    newSAReward = context.Query <Common.Api.ExigoOData.Rewards.NewProductsLaunchReward>(SqlProcedure).FirstOrDefault();
                }

                var eligibleAsNewSA = newSAReward != null && ((customerStartDate >= newSAReward.ThresholdPeriodStart &&
                                                               customerStartDate <= newSAReward.ThresholdPeriodEnd) && newSAReward.Credits == 998 && newSAReward.PRVThresholdMin == 0); // 998 is when you are eligible for all products as a new SA
                //var availableRewrads = context.NewProductsLaunchRewards.Where(c => c.Credits != 998 && c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now && (c.PRVThresholdMin <= eligiblePRV && eligiblePRV <= c.PRVThresholdMax)).FirstOrDefault();
                Common.Api.ExigoOData.Rewards.NewProductsLaunchReward availableRewrads = null;

                using (var context = Exigo.Sql())
                {
                    var SqlProcedure = string.Format("availableRewrads '{0}',{1},{2}", DateTime.Now, 998, eligiblePRV);
                    availableRewrads = context.Query <Common.Api.ExigoOData.Rewards.NewProductsLaunchReward>(SqlProcedure).FirstOrDefault();
                }
                return(eligibleAsNewSA ? newSAReward : availableRewrads);
            }
            catch (Exception ex)
            {
                throw;
            }
        }