public GamesSyncResult( IEnumerable <GameRow> gameRows, IEnumerable <Game> games) { var gameRowsByID = gameRows.ToDictionary(r => r.ID); var gamesByID = games.ToDictionary(g => g.ID); DefunctGameRows = gameRowsByID.Values .Where(r => !gamesByID.ContainsKey(r.ID)) .ToArray(); NewGameRows = GameRow.CreateRows(gamesByID.Values .Where(g => !gameRowsByID.ContainsKey(g.ID))) .ToArray(); UpdatedFields = new HashSet <string>(); var updatedGameRows = new List <GameRow>(); foreach (var game in gamesByID.Values) { if (gameRowsByID.TryGetValue(game.ID, out GameRow gameRow) && !game.Matches(gameRow)) { UpdatedFields.UnionWith(game.GetUpdatedFields(gameRow)); game.CopyTo(gameRow); updatedGameRows.Add(gameRow); } } UpdatedGameRows = updatedGameRows; }
public GameRow AddGameRow(string titleId, string discId, string name) { GameRow rowGameRow = ((GameRow)(this.NewRow())); object[] columnValuesArray = new object[] { titleId, discId, name }; rowGameRow.ItemArray = columnValuesArray; this.Rows.Add(rowGameRow); return(rowGameRow); }
public async Task <Game> CreateGame(Game game) { const string query = @"INSERT INTO dbo.Game(Name) VALUES(@Name); SELECT Name FROM dbo.Game WHERE Id = SCOPE_IDENTITY();"; GameRow row = GameRow.FromDomain(game); string result = ""; using (var conn = new SqlConnection(_connectionStr)) { result = (await conn.QueryAsync <string>(query, row)).First(); } return(await LoadGame(result)); }
private GameRow[] convertBoardtoRows(GamePiece[] board) { var rows = new GameRow[ROWS]; for (int i = 0; i < rows.Length; i++) { rows[i] = new GameRow(); } for (int i = 1; i < board.Length; i++) { if (board[i] != null) { rows[ComputeRow(i)].Row.Add(board[i]); } } return(rows); }
protected void btnAdd_Click(object sender, EventArgs e) { //Instantiate the CustomerCart object if (Session["CustomerCart"] == null) { Session["CustomerCart"] = new ShopCart(); } //Access the ProductPK from the DataKeys collection of the DataList int intID = Convert.ToInt32(dlGame.DataKeys[0]); //Get details about the game from the database //Note: These details could have been obtained from the DataList too using (GameTableAdapter aAdapter = new GameTableAdapter()) { GameDataTable aTable; aTable = aAdapter.GetDataByGameID(intID); if (aTable.Rows.Count == 1) { GameRow aRow = aTable.Rows[0] as GameRow; //Add the CartItem if (aRow.stock <= 0) { Response.Redirect("~/home.aspx"); } ShopCart aCart = Session["CustomerCart"] as ShopCart; aCart.AddCartItem(aRow.gameID, aRow.name, aRow.boxImage, 1, aRow.price, aRow.stock); } } Response.Redirect("~/ShoppingCart.aspx"); }
public GameRowChangeEvent(GameRow row, global::System.Data.DataRowAction action) { this.eventRow = row; this.eventAction = action; }
public void RemoveGameRow(GameRow row) { this.Rows.Remove(row); }
public void AddGameRow(GameRow row) { this.Rows.Add(row); }