public async Task <IActionResult> Edit(int id, [Bind("Id,Name,SubjectId")] SubjectBranch subjectBranch) { if (id != subjectBranch.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(subjectBranch); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubjectBranchExists(subjectBranch.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SubjectId"] = new SelectList(_context.Subjects, "Id", "Name", subjectBranch.SubjectId); return(View(subjectBranch)); }
public async Task <IActionResult> Create([Bind("Id,Name,SubjectId")] SubjectBranch subjectBranch) { if (ModelState.IsValid) { _context.Add(subjectBranch); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["SubjectId"] = new SelectList(_context.Subjects, "Id", "Name", subjectBranch.SubjectId); return(View(subjectBranch)); }