public async Task <IActionResult> Edit(int id, [Bind("GroupHandinId,AssignmentId,Grade,GroupId,TeacherAuId")] GroupHandin groupHandin) { if (id != groupHandin.GroupHandinId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(groupHandin); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GroupHandinExists(groupHandin.GroupHandinId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AssignmentId"] = new SelectList(_context.Assignment, "AssignmentId", "AssignmentName", groupHandin.AssignmentId); ViewData["GroupId"] = new SelectList(_context.Group, "GroupId", "GroupId", groupHandin.GroupId); ViewData["TeacherAuId"] = new SelectList(_context.Teachers, "TeacherAuId", "FirstName", groupHandin.TeacherAuId); return(View(groupHandin)); }
public async Task <IActionResult> Create([Bind("GroupHandinId,AssignmentId,Grade,GroupId,TeacherAuId")] GroupHandin groupHandin) { if (ModelState.IsValid) { _context.Add(groupHandin); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AssignmentId"] = new SelectList(_context.Assignment, "AssignmentId", "AssignmentName", groupHandin.AssignmentId); ViewData["GroupId"] = new SelectList(_context.Group, "GroupId", "GroupId", groupHandin.GroupId); ViewData["TeacherAuId"] = new SelectList(_context.Teachers, "TeacherAuId", "FirstName", groupHandin.TeacherAuId); return(View(groupHandin)); }