public async Task <IActionResult> Edit(int id, [Bind("Id,GameId,PlatformId")] GamesPlatforms gamesPlatforms) { if (id != gamesPlatforms.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(gamesPlatforms); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GamesPlatformsExists(gamesPlatforms.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GameId"] = new SelectList(_context.ComputerGames, "Id", "Name", gamesPlatforms.GameId); ViewData["PlatformId"] = new SelectList(_context.Platforms, "Id", "Name", gamesPlatforms.PlatformId); return(View(gamesPlatforms)); }
public Game(int productId, string productName, decimal price, int stock, ProductType type, GamesStorageDataDevices gamesStorageDataDevices, GamesPlatforms platform, GamesCategory category) : base(productId, productName, price, stock, type) { this.DataStorageDevice = gamesStorageDataDevices; this.Platform = platform; this.category = category; }
private static Product CreateGame(int id, string name, decimal price, int stock, ProductType type, Dictionary <String, String> attributes) { GamesStorageDataDevices dataDevices = (GamesStorageDataDevices)Enum.Parse(typeof(GamesStorageDataDevices), attributes["GamesStorageDataDevices"]); GamesPlatforms platform = (GamesPlatforms)Enum.Parse(typeof(GamesPlatforms), attributes["GamesPlatform"]); GamesCategory category = (GamesCategory)Enum.Parse(typeof(GamesCategory), attributes["GamesCategory"]); return(new Game(id, name, price, stock, type, dataDevices, platform, category)); }
public async Task <IActionResult> Create(int GameId, [Bind("Id,PlatformId")] GamesPlatforms gamesPlatforms) { gamesPlatforms.GameId = GameId; if (ModelState.IsValid) { _context.Add(gamesPlatforms); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("Index", "GamesPlatforms", new { id = GameId, name = _context.ComputerGames.Where(c => c.Id == GameId).FirstOrDefault().Name })); } //ViewData["GameId"] = new SelectList(_context.ComputerGames, "Id", "Engine", gamesPlatforms.GameId); //ViewData["PlatformId"] = new SelectList(_context.Platforms, "Id", "Info", gamesPlatforms.PlatformId); //return View(gamesPlatforms); return(RedirectToAction("Index", "GamesPlatforms", new { id = GameId, name = _context.ComputerGames.Where(c => c.Id == GameId).FirstOrDefault().Name })); }