public async Task <IActionResult> Edit(int id, [Bind("Id,SubsidiariesId,GameId")] GamesDevelopers gamesDevelopers) { if (id != gamesDevelopers.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(gamesDevelopers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GamesDevelopersExists(gamesDevelopers.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GameId"] = new SelectList(_context.ComputerGames, "Id", "Engine", gamesDevelopers.GameId); ViewData["SubsidiariesId"] = new SelectList(_context.Subsidiaries, "Id", "Location", gamesDevelopers.SubsidiariesId); return(View(gamesDevelopers)); }
public async Task <IActionResult> Create(int SubsidiariesId, [Bind("Id,GameId")] GamesDevelopers gamesDevelopers) { gamesDevelopers.SubsidiariesId = SubsidiariesId; if (ModelState.IsValid) { _context.Add(gamesDevelopers); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("Index", "GamesDevelopers", new { id = SubsidiariesId, name = _context.Subsidiaries.Where(s => s.Id == SubsidiariesId).FirstOrDefault().Name })); } //ViewData["GameId"] = new SelectList(_context.ComputerGames, "Id", "Engine", gamesDevelopers.GameId); //ViewData["SubsidiariesId"] = new SelectList(_context.Subsidiaries, "Id", "Location", gamesDevelopers.SubsidiariesId); return(RedirectToAction("Index", "GamesDevelopers", new { id = SubsidiariesId, name = _context.Subsidiaries.Where(s => s.Id == SubsidiariesId).FirstOrDefault().Name })); }