public async static Task <ConcurrentDictionary <int, AntiMine> > GetAntiMines(int playerID) { ConcurrentDictionary <int, AntiMine> antiMines = new ConcurrentDictionary <int, AntiMine>(); Func <SqlConnection, Task> readerProcedure = async(SqlConnection connection) => { SqlDataReader reader; SqlCommand cmd = new SqlCommand("GetAntiMines", connection); //TODO: Setup Database Stored Procedure cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@playerID", SqlDbType.Int).Value = playerID; reader = await cmd.ExecuteReaderAsync(); while (reader.Read()) { int cellID = (int)reader["CellID"]; AntiMine aMine = new AntiMine(cellID, playerID); antiMines.TryAdd(cellID, aMine); } reader.Close(); }; await ExecuteQueryAsync(readerProcedure); return(antiMines); }
private async void AntiMineBtn_Click(object sender, EventArgs e) { if (GameModel.Player.Wallet.Confinium >= GameModel.ANTI_MINE_BASE_PRICE) { AntiMine aMine = await GameModel.Player.CreateAntiMine(cellClicked.ID); GameModel.CellsInView[aMine.CellID].MapOverlay.Draw(((MapActivity)Activity).Map); aMine.MapActivity = ((MapActivity)Activity); aMine.Start(); Toast.MakeText(Context, "Anti Mine Placed!", ToastLength.Long).Show(); } else { Toast.MakeText(Context, "You don't have enough confinium in your wallet to purchase an AntiMine. ", ToastLength.Long).Show(); } }