private static void CreditWinner(Jackpot jackpot, JackpotWinningTicket winningTicket, Member winner) { var prizeType = GetPrizeType(jackpot, winner); switch (prizeType) { case JackpotPrize.MainBalance: var mainBalancePrize = jackpot.MainBalancePrize / jackpot.NumberOfWinningTickets; winner.AddToMainBalance(mainBalancePrize, "Jackpot win", BalanceLogType.Other); winner.SaveBalances(); History.AddJackpotWin(winner.Name, string.Format("{0} - {1}", L1.MAINBALANCE, mainBalancePrize.ToString()), winningTicket.WinningTicketNumber.ToString(), jackpot.Name); PoolDistributionManager.SubtractProfit(ProfitSource.Jackpots, mainBalancePrize); break; case JackpotPrize.AdBalance: var adBalancePrize = jackpot.AdBalancePrize / jackpot.NumberOfWinningTickets; winner.AddToPurchaseBalance(adBalancePrize, "Jackpot win", BalanceLogType.Other); winner.SaveBalances(); History.AddJackpotWin(winner.Name, string.Format("{0} - {1}", U6012.PURCHASEBALANCE, adBalancePrize.ToString()), winningTicket.WinningTicketNumber.ToString(), jackpot.Name); PoolDistributionManager.SubtractProfit(ProfitSource.Jackpots, adBalancePrize); break; case JackpotPrize.LoginAdsCredits: var loginAdsCreditsPrize = jackpot.LoginAdsCreditsPrize / jackpot.NumberOfWinningTickets; winner.AddToLoginAdsCredits(loginAdsCreditsPrize, "Jackpot win"); winner.SaveBalances(); History.AddJackpotWin(winner.Name, string.Format("{0} - {1}", U5008.LOGINADSCREDITS, loginAdsCreditsPrize.ToString()), winningTicket.WinningTicketNumber.ToString(), jackpot.Name); break; case JackpotPrize.Upgrade: var upgradeMembershipDaysPrize = jackpot.UpgradeDaysPrize / jackpot.NumberOfWinningTickets; if (winner.MembershipId == Membership.Standard.Id) { winner.Upgrade(new Membership(jackpot.UpgradeIdPrize), new TimeSpan(upgradeMembershipDaysPrize, 0, 0, 0)); } else { winner.Upgrade(new Membership(jackpot.UpgradeIdPrize), winner.MembershipExpires.HasValue ? winner.MembershipExpires.Value.AddDays(upgradeMembershipDaysPrize) : AppSettings.ServerTime.AddDays(upgradeMembershipDaysPrize)); } History.AddJackpotWin(winner.Name, string.Format("{0} - {1}", U5008.UPGRADED, winner.Membership.Name), winningTicket.WinningTicketNumber.ToString(), jackpot.Name); break; default: break; } JackpotTicketPrize prize = new JackpotTicketPrize(); prize.JackpotId = jackpot.Id; prize.PrizeType = prizeType; prize.Save(); }