private IResultGenericWrapper <ResultRoulette> GetResultBetsToRoulette(Roulette roulette) { ResultRoulette resultRoulette = GetResultRoulette(roulette); resultRoulette.Bets = GetResultBets(roulette.Bets, resultRoulette); return(new ResultGenericWrapper <ResultRoulette>(error: false, message: "", result: resultRoulette)); }
private List <Bet> GetResultBets(List <Bet> bets, ResultRoulette resultRoulette) { foreach (var bet in bets) { bet.EarnedMoney = GetEarnedMoneyBet(bet, resultRoulette); } return(bets); }
private ResultRoulette GetResultRoulette(Roulette roulette) { ResultRoulette resultRoulette = new ResultRoulette(); resultRoulette.WinningNumber = GetWinningNumberRoulette(); resultRoulette.WinningColor = GetWinningColorRoulette(resultRoulette.WinningNumber); return(resultRoulette); }
private decimal GetEarnedMoneyBet(Bet bet, ResultRoulette resultRoulette) { if (bet.Type == TypeBet.Number && bet.Number == resultRoulette.WinningNumber) { return(bet.Amount * 5); } if (bet.Type == TypeBet.Color && bet.Color.Equals(resultRoulette.WinningColor)) { return(bet.Amount * 1.8m); } return(0); }
/// <summary> /// Closed the roulette /// </summary> /// <param name="roulette"></param> /// <returns>List the bets</returns> public async Task <ResultRoulette> ClosedRoulette(Roulette roulette) { var result = await _rouletteService.ClosedRoulette(roulette); if (result) { var resultRoulette = new ResultRoulette { ResultNumber = GenerateNumber() }; var betsRoulette = await _rouletteService.GetBetsRoulette(roulette); resultRoulette.BetRoulettes = ProccesRoulette(betsRoulette, resultRoulette.ResultNumber); return(resultRoulette); } return(null); }