public async Task <IActionResult> Edit(int id, [Bind("TeamId,Name,CityId")] Team team) { if (id != team.TeamId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(team); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeamExists(team.TeamId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CityId"] = new SelectList(_context.Cities, "CityId", "Name", team.CityId); return(View(team)); }
public async Task <IActionResult> Edit(int id, int cityId, [Bind("StadiumId,Name,CityId")] Stadium stadium) { stadium.CityId = cityId; if (id != stadium.StadiumId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(stadium); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StadiumExists(stadium.StadiumId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index", "Stadia", new { id = cityId, name = _context.Cities.Where(c => c.CityId == cityId).FirstOrDefault().Name })); } //ViewData["CityId"] = new SelectList(_context.Cities, "CityId", "Name", stadium.CityId); return(RedirectToAction("Index", "Stadia", new { id = cityId, name = _context.Cities.Where(c => c.CityId == cityId).FirstOrDefault().Name })); }
public async Task <IActionResult> Edit(int id, [Bind("CityId,Name")] City city) { if (id != city.CityId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(city); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CityExists(city.CityId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(city)); }
public async Task <IActionResult> Edit(int id, [Bind("RefereeId,FullName,BirthDate")] Referee referee) { if (id != referee.RefereeId) { return(NotFound()); } if (referee.BirthDate < new DateTime(1950, 12, 1)) { ModelState.AddModelError("BirthDate", "Дата народження повина бути більша за 01.12.1950"); } if (ModelState.IsValid) { try { _context.Update(referee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RefereeExists(referee.RefereeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(referee)); }
public async Task <IActionResult> Edit(int id, [Bind("PlayerId,FullName")] Player player) { if (id != player.PlayerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(player); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlayerExists(player.PlayerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(player)); }
public async Task <IActionResult> Edit(int id, [Bind("GameId,StartTime,StadiumId,TournamentId,TeamId,TeamId2,RefereeId")] Game game) { if (id != game.GameId) { return(NotFound()); } if (game.TeamId == game.TeamId2) { ModelState.AddModelError("TeamId", "Помилкова пара команд"); } if (game.StartTime < new DateTime(1970, 12, 1)) { ModelState.AddModelError("StartTime", "Час доступний 1970 р.н.е. і далі"); } if (ModelState.IsValid) { try { _context.Update(game); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GameExists(game.GameId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["RefereeId"] = new SelectList(_context.Referees, "RefereeId", "FullName", game.RefereeId); ViewData["StadiumId"] = new SelectList(_context.Stadiums, "StadiumId", "Name", game.StadiumId); ViewData["TeamId"] = new SelectList(_context.Teams, "TeamId", "Name", game.TeamId); ViewData["TeamId2"] = new SelectList(_context.Teams, "TeamId", "Name", game.TeamId2); ViewData["TournamentId"] = new SelectList(_context.Tournaments, "TournamentId", "Name", game.TournamentId); return(View(game)); }
public async Task <IActionResult> Edit(int id, int playerId, [Bind("CareerId,TeamId,PlayerId,StartDate,EndDate,PositionId")] Career career) { career.PlayerId = playerId; if (career.EndDate != null && career.StartDate > career.EndDate) { ModelState.AddModelError("StartDate", "Невірний часовий проміжок"); } if (id != career.CareerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(career); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CareerExists(career.CareerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index", "Careers", new { id = playerId, name = _context.Players.Where(c => c.PlayerId == playerId).FirstOrDefault().FullName })); } //ViewData["PlayerId"] = new SelectList(_context.Players, "PlayerId", "FullsName", career.PlayerId); //ViewData["PositionId"] = new SelectList(_context.Positions, "PositionId", "Name", career.PositionId); //ViewData["TeamId"] = new SelectList(_context.Teams, "TeamId", "Name", career.TeamId); return(RedirectToAction("Index", "Careers", new { id = playerId, name = _context.Players.Where(c => c.PlayerId == playerId).FirstOrDefault().FullName })); }
public async Task <IActionResult> Edit(int id, [Bind("TournamentId,Name,Prize,StartDate,EndDate,Info")] Tournament tournament) { if (id != tournament.TournamentId) { return(NotFound()); } if (tournament.StartDate > tournament.EndDate) { ModelState.AddModelError("StartDate", "Невірний часовий проміжок"); } if (tournament.Prize > 1000000000 || tournament.Prize < 0) { ModelState.AddModelError("Prize", "Сума повинна бути менше одного мільярда, і більше нуля"); } if (ModelState.IsValid) { try { _context.Update(tournament); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TournamentExists(tournament.TournamentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tournament)); }