Ejemplo n.º 1
0
        private bool SetNewAffiliate(string referrerId, string referrerUrl, MerchantTribeApplication app)
        {
            Contacts.Affiliate aff = Affiliates.FindByReferralId(referrerId);
            if (aff == null)
            {
                return(false);
            }
            if (!aff.Enabled)
            {
                return(false);
            }

            if (aff.Id != SessionManager.CurrentAffiliateID(app.CurrentStore))
            {
                System.DateTime expires = System.DateTime.UtcNow;
                if (aff.ReferralDays > 0)
                {
                    TimeSpan ts = new TimeSpan(aff.ReferralDays, 0, 0, 0);
                    expires = expires.Add(ts);
                }
                else
                {
                    expires = System.DateTime.UtcNow.AddYears(50);
                }
                SessionManager.SetCurrentAffiliateId(aff.Id, expires, app.CurrentStore);
            }
            return(LogReferral(aff.Id, referrerUrl));
        }
Ejemplo n.º 2
0
        private bool LogReferral(long affiliateId, string referrerUrl)
        {
            Contacts.Affiliate aff = Affiliates.Find(affiliateId);
            if (aff == null)
            {
                return(false);
            }
            if (!aff.Enabled)
            {
                return(false);
            }

            AffiliateReferral r = new AffiliateReferral();

            r.AffiliateId = aff.Id;
            r.ReferrerUrl = referrerUrl;
            return(AffiliateReferrals.Create(r));
        }
Ejemplo n.º 3
0
        public long GetValidAffiliateId(MerchantTribeApplication app)
        {
            long current = SessionManager.CurrentAffiliateID(app.CurrentStore);

            if (current < 0)
            {
                return(0);
            }

            Contacts.Affiliate aff = Affiliates.Find(current);
            if (aff == null)
            {
                return(0);
            }
            if (!aff.Enabled)
            {
                return(0);
            }

            return(current);
        }