public async Task <IActionResult> PutSubject(Guid id, SubjectModel subjectModel) { if (id != subjectModel.Id) { return(BadRequest()); } var subject = await _context.Subjects.FindAsync(id); if (subject == null) { return(NotFound()); } subject.Name = subjectModel.Name; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) when(!SubjectExists(id)) { return(NotFound()); } return(NoContent()); }
public async Task <IActionResult> Create([Bind("DepartmentId,DepartmentName")] Department department) { if (ModelState.IsValid) { _context.Add(department); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(department)); }
public async Task <IActionResult> Create([Bind("SubjectId,SubjectName,Duration,DepartmentId")] Subject subject) { if (ModelState.IsValid) { _context.Add(subject); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DepartmentId"] = new SelectList(_context.Departments, "DepartmentId", "DepartmentName", subject.DepartmentId); return(View(subject)); }