public async Task <IActionResult> Edit(int id, [Bind("Id,DateRegistered,LandownerId")] TrapUser trapUser) { if (id != trapUser.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(trapUser); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TrapUserExists(trapUser.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["LandownerId"] = new SelectList(_context.Landowner, "Id", "Id", trapUser.LandownerId); return(View(trapUser)); }
public async Task <IActionResult> Create([Bind("Id,DateRegistered,LandownerId")] TrapUser trapUser) { if (ModelState.IsValid) { _context.Add(trapUser); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["LandownerId"] = new SelectList(_context.Landowner, "Id", "Id", trapUser.LandownerId); return(View(trapUser)); }