public bool Update(int id, string title, string description, string image, decimal price, double size, string videoId, DateTime releaseDate) { using (var context = new GameStoreDbContext()) { var game = context.Games.FirstOrDefault(g => g.Id == id); if (game == null) { return(false); } game.Title = title; game.Description = description; game.ImageUrl = image; game.Price = price; game.Size = size; game.VideoId = videoId; game.ReleaseDate = releaseDate; context.Update(game); context.SaveChanges(); return(true); } }
public bool Edit(int id, string title, string description, string image, decimal price, double size, string videoId, DateTime releaseDate) { using (var db = new GameStoreDbContext()) { var game = db.Games.Find(id); if (game == null) { return(false); } game.Title = title; game.Description = description; game.ImageUrl = image; game.Price = price; game.Size = size; game.VideoId = videoId; game.ReleaseDate = releaseDate; db.Update(game); db.SaveChanges(); } return(true); }