Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.ReferralPoolRotatorEnabled);

        if (!IsPostBack)
        {            
            Button1.Text = L1.MANAGE;
            Button2.Text = ParticipateButton.Text = L1.BUY;
            int UserId = Member.CurrentId;

            if (PoolRotatorManager.IsInPool(UserId))
            {
                ParticipatePlaceHolder.Visible = true;
                NoParticipatePlaceHolder.Visible = false;

                var linkUser = PoolRotatorManager.Get(UserId);

                LinkOpensLabel.Text = linkUser.ClicksDelivered.ToString();
                //ReferralsGainedLabel.Text = linkUser.ReferralsDelivered.ToString();
                RotatorExpiresLiteral.Text = linkUser.Expires.ToString();
                RotatorLinkLiteral.Text = String.Format("<a href='{0}'>{0}</a>", linkUser.GetLink());
            }

            if (selectedBalance == RotatorBalance.AdCredits)
                PriceLiteral.Text = AppSettings.Referrals.ReferralPoolRotatorPricePerMonthInAdCredits.ToString() + " " + U5006.ADCREDITS;
            else if (selectedBalance == RotatorBalance.AdBalance)
                PriceLiteral.Text = AppSettings.Referrals.ReferralPoolRotatorPricePerMonth.ToString();

            PriceLiteral.Text += " / 30 " + L1.DAYS.ToLower();
            MembersInPoolLabel.Text = PoolRotatorStatistics.MembersInThePool.ToString();
        }
    }
Пример #2
0
    public void ParticipateButton_Click(object sender, EventArgs e)
    {
        SPanel.Visible = false;
        EPanel.Visible = false;

        try
        {
            Member user = Member.Current;
            if (selectedBalance == RotatorBalance.AdCredits)
            {
                if (user.PTCCredits < AppSettings.Referrals.ReferralPoolRotatorPricePerMonthInAdCredits)
                    throw new MsgException(L1.NOTENOUGHFUNDS);

                user.SubstractFromPTCCredits(AppSettings.Referrals.ReferralPoolRotatorPricePerMonthInAdCredits, "Rotator Link");
            }

            else if (selectedBalance == RotatorBalance.AdBalance)
            {
                if (user.PurchaseBalance < AppSettings.Referrals.ReferralPoolRotatorPricePerMonth)
                    throw new MsgException(L1.NOTENOUGHFUNDS);

                user.SubtractFromPurchaseBalance(AppSettings.Referrals.ReferralPoolRotatorPricePerMonth, "Rotator Link");
            }
            user.SaveBalances();

            if (PoolRotatorManager.IsInPool(user.Id))
            {
                //Prolong
                var link = PoolRotatorManager.Get(user.Id);
                link.Expires = link.Expires.AddDays(30);
                link.Save();
            }
            else
            {
                PoolRotatorManager.AddToPool(user.Id);
            }

            SPanel.Visible = true;
            SText.Text = L1.OP_SUCCESS;
        }
        catch (MsgException ex)
        {
            EPanel.Visible = true;
            EText.Text = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex);
        }
    }