public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Sourname,Position,NationalId,ClubId,GoalsNumber,AssistsNumber,DateOfBirth,MatchesNumber")] Footboller footboller) { if (id != footboller.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(footboller); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FootbollerExists(footboller.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ClubId"] = new SelectList(_context.Clubs, "Id", "DateOfBirth", footboller.ClubId); ViewData["NationalId"] = new SelectList(_context.Nationals, "Id", "Name", footboller.NationalId); return(View(footboller)); }
public async Task <IActionResult> Create([Bind("Id,Name,Sourname,Position,NationalId,ClubId,GoalsNumber,AssistsNumber,DateOfBirth,MatchesNumber")] Footboller footboller) { if (ModelState.IsValid) { _context.Add(footboller); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ClubId"] = new SelectList(_context.Clubs, "Id", "Name", footboller.ClubId); ViewData["NationalId"] = new SelectList(_context.Nationals, "Id", "Name", footboller.NationalId); return(View(footboller)); }