Ejemplo n.º 1
0
        public Money CreditMember(PtcAdvert Ad, bool isFromAutosurf = false)
        {
            Money Calculated = PtcAdvert.CalculateNormalMemberEarnings(User, Ad);

            base.CreditMainBalance(Calculated, "PTC", BalanceLogType.Other);

            //To not overflow the logs
            if (User.Membership.AdvertPointsEarnings > 0)
            {
                base.CreditPoints(User.Membership.AdvertPointsEarnings, "PTC", BalanceLogType.Other);
            }

            //Ad Credits?
            if (AppSettings.PtcAdverts.PTCCreditsEnabled)
            {
                User.AddToPTCCredits(User.Membership.PTCCreditsPerView, "PTC");

                //Credit advertiser
                if (Ad.Advertiser.Is(Advertiser.Creator.Member) && Ad.AdvertiserUserId != User.Id)
                {
                    Member UplineAdvertiser = new Member(Ad.AdvertiserUserId);
                    UplineAdvertiser.AddToPointsBalance(UplineAdvertiser.Membership.PointsYourPTCAdBeingViewed, "PTC Ad Viewed");
                    UplineAdvertiser.SaveBalances();
                    Ad.PointsEarnedFromViews += UplineAdvertiser.Membership.PointsYourPTCAdBeingViewed;
                    Ad.Save();
                }
            }

            //OK mark as watched and credit
            List <int> av = User.AdsViewed;

            av.Add(Ad.Id);
            User.AdsViewed  = av;
            User.LastActive = DateTime.Now;

            if (isFromAutosurf)
            {
                User.PtcAutoSurfClicksThisMonth += 1;
            }

            User.PtcSurfClicksThisMonth += 1;

            //Achievements
            User.TryToAddAchievements(
                Prem.PTC.Achievements.Achievement.GetProperAchievements(
                    Prem.PTC.Achievements.AchievementType.AfterClicks, User.TotalClicks + 1));

            Money NewTotalEarned = (User.TotalEarned + Calculated);

            User.TryToAddAchievements(
                Prem.PTC.Achievements.Achievement.GetProperAchievements(
                    Prem.PTC.Achievements.AchievementType.AfterEarning, NewTotalEarned.GetRealTotals()));

            User.IncreaseUserStatClicks(1);
            User.IncreaseStatClicks(1);
            User.IncreaseCashLinksEarnings(Calculated);

            //Slot machine chances
            SlotMachine.SlotMachine.TryAddChances(User);

            User.Save();

            //Check the contests
            Prem.PTC.Contests.ContestManager.IMadeAnAction(Prem.PTC.Contests.ContestType.Click, User.Name, null, 1);

            var rrm = new RentReferralsSystem(User.Name, User.Membership);

            rrm.IClicked(Ad);

            TryCreditDirectReferer(Ad);

            return(Calculated);
        }
Ejemplo n.º 2
0
    public override void DataBind()
    {
        base.DataBind();

        if (Member.IsLogged)
        {
            Member user = Member.CurrentInCache;

            UserEarnedMoney   = PtcAdvert.CalculateNormalMemberEarnings(user, Object);
            EarningsDR        = PtcAdvert.CalculateEarningsFromDirectReferral(user, Object);
            EarningsRR        = PtcAdvert.CalculateEarningsFromRentedReferral(user, Object);
            EarningsPoints    = user.Membership.AdvertPointsEarnings;
            EarningsAdCredits = user.Membership.PTCCreditsPerView;
        }
        else
        {
            //Public ad view
            UserEarnedMoney   = PtcAdvert.CalculateNormalMemberEarnings(Membership.Standard, Object);
            EarningsDR        = PtcAdvert.CalculateEarningsFromDirectReferral(Membership.Standard, Object);
            EarningsRR        = PtcAdvert.CalculateEarningsFromRentedReferral(Membership.Standard, Object);
            EarningsPoints    = Membership.Standard.AdvertPointsEarnings;
            EarningsAdCredits = Membership.Standard.PTCCreditsPerView;
        }

        //Display PTC Advert Type
        if (AppSettings.PtcAdverts.CashLinkViewEnabled == AppSettings.PTCViewMode.PTC)
        {
            //Starred Ads
            if (Object.IsStarredAd)
            {
                starImg.Visible  = true;
                starImg2.Visible = true;
            }
            else
            {
                starImg.Visible  = false;
                starImg2.Visible = false;
            }

            //Favorite Ads
            if (AppSettings.PtcAdverts.FavoriteAdsEnabled && Member.IsLogged &&
                FavoriteAd.IsFavorite(Member.CurrentId, Object.Id, FavoriteAdType.PTC))
            {
                favoriteImg.Visible  = true;
                favoriteImg2.Visible = true;
                FavoriteCssClass     = " fav";
            }
            else
            {
                favoriteImg.Visible  = false;
                favoriteImg2.Visible = false;
            }

            if (IsActive)
            {
                ActiveAdvertPlaceHolder.Visible = true;
            }
            else
            {
                InactiveAdvertPlaceHolder.Visible = true;
            }

            if (ImageUrl != null)
            {
                //    PtcImage.ImageUrl = PtcImage2.ImageUrl = ImageUrl;
                ImageBackgroundStyle = "background: url(" + ResolveUrl(ImageUrl) + ");";
            }


            if (AppSettings.PtcAdverts.PTCImagesEnabled)
            {
                ImageClass = "has-image";
            }
            else
            {
                ImageClass = "";
            }

            CashLinkPlaceHolder.Visible = false;
        }
        //Display Cash Links Advert Type
        else if (AppSettings.PtcAdverts.CashLinkViewEnabled == AppSettings.PTCViewMode.CashLink)
        {
            ActiveAdvertPlaceHolder.Visible   = false;
            InactiveAdvertPlaceHolder.Visible = false;
            if (IsActive)
            {
                CashLinkPlaceHolder.Visible = true;
            }
            else
            {
                CashLinkPlaceHolderInActive.Visible = true;
            }

            if (IsPreview) //Preview fix
            {
                CashLinkDiv.Attributes["class"] = "Abox CashLinkBox";
            }
        }
    }