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 async Task <IActionResult> Edit(int id, [Bind("Id,Genre")] Genres genres) { if (id != genres.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(genres); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GenresExists(genres.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(genres)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Location,CompanyId,ManagerFullName")] Subsidiaries subsidiaries) { if (id != subsidiaries.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(subsidiaries); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubsidiariesExists(subsidiaries.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CompanyId"] = new SelectList(_context.GameDevCompanies, "Id", "DirectorFullName", subsidiaries.CompanyId); return(View(subsidiaries)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Info")] Distributors distributors) { if (id != distributors.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(distributors); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DistributorsExists(distributors.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(distributors)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Location,DirectorFullName")] GameDevCompanies gameDevCompanies) { if (id != gameDevCompanies.Id) { return(NotFound()); } GameDevCompanies existingCompany = await _context.GameDevCompanies.FirstOrDefaultAsync( c => c.Name == gameDevCompanies.Name && c.Location == gameDevCompanies.Location); if (existingCompany != null) { ModelState.AddModelError(string.Empty, "This company already exists."); } else if (ModelState.IsValid) { try { _context.Update(gameDevCompanies); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GameDevCompaniesExists(gameDevCompanies.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(gameDevCompanies)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Budget,Engine")] ComputerGames computerGames) { if (id != computerGames.Id) { return(NotFound()); } ComputerGames existingGame = await _context.ComputerGames.FirstOrDefaultAsync( g => g.Name == computerGames.Name); if (existingGame != null) { ModelState.AddModelError(string.Empty, "This game already exists."); } else if (ModelState.IsValid) { try { _context.Update(computerGames); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ComputerGamesExists(computerGames.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(computerGames)); }