public async Task <IActionResult> Edit(int id, [Bind("MatchId,MatchName,MatchResult,FirstClubId,SecondClubId,MatchDate")] ClubMatch clubMatch) { if (id != clubMatch.MatchId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(clubMatch); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClubMatchExists(clubMatch.MatchId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FirstClubId"] = new SelectList(_context.Clubs, "ClubId", "ClubId", clubMatch.FirstClubId); ViewData["SecondClubId"] = new SelectList(_context.Clubs, "ClubId", "ClubId", clubMatch.SecondClubId); return(View(clubMatch)); }
public async Task <IActionResult> Create([Bind("MatchId,MatchName,MatchResult,FirstClubId,SecondClubId,MatchDate")] ClubMatch clubMatch) { if (clubMatch.FirstClubId != clubMatch.SecondClubId) { if (ModelState.IsValid) { _context.Add(clubMatch); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } ViewData["FirstClubId"] = new SelectList(_context.Clubs, "ClubId", "ClubName"); ViewData["SecondClubId"] = new SelectList(_context.Clubs, "ClubId", "ClubName"); return(View(clubMatch)); }