Esempio n. 1
0
        public static void DepositOnLevel(InvestmentPlatformPlan platformPlan, int userPlanId, Member user)
        {
            if (!LevelsEnabled)
            {
                return;
            }

            var ticket = AddNewTicket(platformPlan, user.Id, userPlanId);

            //We want to give users money only on every second deposit
            if (ticket.TicketNumber % 2 == 0)
            {
                var targetTicket  = GetFirstUnpaidTicketFromLevel(ticket.Level);
                var targetUser    = new Member(targetTicket.UserId);
                var targetPP      = platformPlan.PaymentProcessor;
                var payoutManager = new PayoutManager(targetUser, targetTicket.LevelEarnings, targetPP.ToString(), false, 0, string.Empty);

                if (payoutManager.TryMakeInvestmentLevelsPayout())
                {
                    targetTicket.Status = TicketStatus.Finished;
                    targetTicket.Save();

                    var targetPlan = new InvestmentUsersPlans(targetTicket.UserPlanId);
                    targetPlan.Finish();
                }
            }
        }