示例#1
0
        public Money Credit(Money Calculated, CreditAs As, int offerId, string OfferTitle, int CPACompletedIncreasedBy = 1, bool isReversal = false,
                            string NetworkName = "")
        {
            string balanceLogsNote    = "CPA offer (" + (NetworkName != "" ? NetworkName + ": " : "") + OfferTitle + ") ";
            string balanceLogsNoteRef = "CPA offer " + "/ref/" + User.Name + " (" + (NetworkName != "" ? NetworkName + ": " : "") + OfferTitle + ") ";


            if (As == CreditAs.Points)
            {
                Calculated = CLP.CLPManager.ProceedWithCPA(Calculated.GetRealTotals(), User, isReversal);
                base.CreditPoints(Calculated.GetRealTotals(), balanceLogsNote, BalanceLogType.Other);
                base.CreditReferersPoints(Calculated.GetRealTotals(), balanceLogsNoteRef, BalanceLogType.Other);

                if (isReversal == false)
                {
                    History.AddCPAOfferCompleted(User.Name, OfferTitle, Calculated.GetRealTotals().ToString() + " " + AppSettings.PointsName, NetworkName, offerId);
                }

                Mailer.TryToSendCPACreditedMessage(User, Resources.L1.HISTORY_10 + ": " + OfferTitle + "(" + Calculated.GetRealTotals().ToString() + " " + AppSettings.PointsName + ")");
            }
            if (As == CreditAs.MainBalance)
            {
                Calculated = CLP.CLPManager.ProceedWithCPA(Calculated, User, isReversal);
                base.CreditMainBalance(Calculated, balanceLogsNote, BalanceLogType.Other);
                base.CreditReferersMainBalance(Calculated, balanceLogsNoteRef, BalanceLogType.Other, 1, null, true);

                if (isReversal == false)
                {
                    History.AddCPAOfferCompleted(User.Name, OfferTitle, Calculated.ToString(), NetworkName, offerId);
                }

                Mailer.TryToSendCPACreditedMessage(User, Resources.L1.HISTORY_10 + ": " + OfferTitle + "(" + Calculated.ToString() + ")");
            }

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

            //Achievements trial
            User.TryToAddAchievements(
                Prem.PTC.Achievements.Achievement.GetProperAchievements(
                    Prem.PTC.Achievements.AchievementType.AfterCPAOffersCompleted, User.TotalCPACompleted));

            User.Save();

            if (!isReversal)
            {
                if (CPAOfferContestManager.IsIncludedInContest(offerId))
                {
                    ContestManager.IMadeAnAction(Prem.PTC.Contests.ContestType.Offer, User.Name, null, 1);
                }
            }
            else
            {
                if (CPAOfferContestManager.IsIncludedInContest(offerId))
                {
                    ContestManager.IMadeAnAction(Prem.PTC.Contests.ContestType.Offer, User.Name, null, -1);
                }
            }

            return(Calculated);
        }