Esempio n. 1
0
        public static void BuyPack(Member user, MembershipPack pack, PurchaseBalances targetBalance)
        {
            Money packPrice = pack.Price;

            PurchaseOption.ChargeBalance(user, pack.GetPrice(user), PurchaseOption.Features.Upgrade.ToString(), targetBalance, "Upgrade");

            AddPack(user, pack);
        }
Esempio n. 2
0
        public static void AddPack(Member user, MembershipPack pack, Money paidAmountToValidate = null)
        {
            Money PackPrice = pack.GetPrice(user);

            if (paidAmountToValidate != null && paidAmountToValidate < PackPrice)
            {
                throw new MsgException(string.Format("{0} is not enough to buy the chosen Membership ({1} - {2})", paidAmountToValidate, pack.Membership.Name, PackPrice));
            }

            user.Upgrade(pack);

            //Add history entry
            History.AddUpgradePurchase(user.Name, pack.Membership.Name, PackPrice);

            //Update pack stats
            pack.CopiesBought++;
            pack.Save();

            //Credit Balances Bonuses
            var AdBalanceBonus      = pack.Membership.AdBalanceBonusForUpgrade;
            var CashBalanceBonus    = pack.Membership.CashBalanceBonusForUpgrade;
            var TrafficBalanceBonus = pack.Membership.TrafficBalanceBonusForUpgrade;

            if (AdBalanceBonus > Money.Zero)
            {
                user.AddToPurchaseBalance(AdBalanceBonus, "Bonus from Upgrade");
            }

            if (AppSettings.Payments.CashBalanceEnabled && CashBalanceBonus > Money.Zero)
            {
                user.AddToCashBalance(CashBalanceBonus, "Bonus from Upgrade");
            }

            if (AppSettings.TitanFeatures.EarnTrafficExchangeEnabled && TrafficBalanceBonus > Money.Zero)
            {
                user.AddToTrafficBalance(TrafficBalanceBonus, "Bonus from Upgrade");
            }

            var moneyLeftForPools = PackPrice;

            Titan.UpgradeCrediter Crediter = (Titan.UpgradeCrediter)Titan.CrediterFactory.Acquire(user, Titan.CreditType.Upgrade);
            moneyLeftForPools = Crediter.CreditReferer(PackPrice);

            //LeadershipSystem
            var list = new List <RestrictionKind>();

            list.Add(RestrictionKind.RequiredMembership);
            LeadershipSystem.CheckSystem(list, user);

            //Pools
            PoolDistributionManager.AddProfit(ProfitSource.Memberships, moneyLeftForPools);
        }
Esempio n. 3
0
        public static Money GetPricePerDay(int packId)
        {
            var   packs  = MembershipPack.SelectPacksAssignedToMembership(packId);
            Money result = new Money(2000000000);

            if (packs.Count == 0)
            {
                result = Money.Zero;
            }

            foreach (var pack in packs)
            {
                Money value = pack.Price / pack.TimeDays;
                if (value < result)
                {
                    result = value;
                }
            }

            return(result);
        }