public async Task UpdateRouletteGames(RouletteGames rouletteGames) { using (SqlConnection sql = new SqlConnection(_connectionString)) { using (SqlCommand cmd = new SqlCommand("usp_ActualizarJugada", sql)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@IdJugada", rouletteGames.IdRouletteGames)); cmd.Parameters.Add(new SqlParameter("@IdRuleta", rouletteGames.IdRoulette)); cmd.Parameters.Add(new SqlParameter("@NroJuego", rouletteGames.NberGames)); cmd.Parameters.Add(new SqlParameter("@IdJugador", rouletteGames.IdPlayer)); cmd.Parameters.Add(new SqlParameter("@TipoApuesta", rouletteGames.KindBet)); cmd.Parameters.Add(new SqlParameter("@ValorTipoApuesta", rouletteGames.ValueKindBet)); cmd.Parameters.Add(new SqlParameter("@MontoApuesta", rouletteGames.AmountBet)); cmd.Parameters.Add(new SqlParameter("@ValorGanador", rouletteGames.ValueWinner)); cmd.Parameters.Add(new SqlParameter("@MontoGanado", rouletteGames.AmountEarned)); cmd.Parameters.Add(new SqlParameter("@Fue_Ganador", rouletteGames.Was_Winner)); cmd.Parameters.Add(new SqlParameter("@EstadoJugada", rouletteGames.ConditionMove)); await sql.OpenAsync(); await cmd.ExecuteNonQueryAsync(); return; } } }
public async Task <ActionResult> ToBet([FromBody] List <RouletteGames> rouletteGames) { foreach (var item in rouletteGames) { RouletteGames objRouletteGames = new RouletteGames(); objRouletteGames.IdRoulette = item.IdRoulette; objRouletteGames.NberGames = item.NberGames; objRouletteGames.IdPlayer = item.IdPlayer; objRouletteGames.KindBet = item.KindBet; objRouletteGames.ValueKindBet = item.ValueKindBet; objRouletteGames.AmountBet = item.AmountBet; objRouletteGames.ValueWinner = ""; objRouletteGames.AmountEarned = 0; objRouletteGames.Was_Winner = false; objRouletteGames.ConditionMove = false; await _datarouletteGames.InsertRouletteGames(objRouletteGames); } return(Ok("Apuesta hecha satisfactoriamente")); }
public async Task <RouletteGames> InsertRouletteGames(RouletteGames rouletteGames) { using (SqlConnection sql = new SqlConnection(_connectionString)) { using (SqlCommand cmd = new SqlCommand("usp_InsertarJugadas", sql)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@IdRuleta", rouletteGames.IdRoulette)); cmd.Parameters.Add(new SqlParameter("@NroJuego", rouletteGames.NberGames)); cmd.Parameters.Add(new SqlParameter("@IdJugador", rouletteGames.IdPlayer)); cmd.Parameters.Add(new SqlParameter("@TipoApuesta", rouletteGames.KindBet)); cmd.Parameters.Add(new SqlParameter("@ValorTipoApuesta", rouletteGames.ValueKindBet)); cmd.Parameters.Add(new SqlParameter("@MontoApuesta", rouletteGames.AmountBet)); cmd.Parameters.Add(new SqlParameter("@ValorGanador", rouletteGames.ValueWinner)); cmd.Parameters.Add(new SqlParameter("@MontoGanado", rouletteGames.AmountEarned)); cmd.Parameters.Add(new SqlParameter("@Fue_Ganador", rouletteGames.Was_Winner)); cmd.Parameters.Add(new SqlParameter("@EstadoJugada", rouletteGames.ConditionMove)); await sql.OpenAsync(); rouletteGames.IdRoulette = Convert.ToInt32(cmd.ExecuteScalar()); } } return(rouletteGames); }