public ActionResult Edit(SubjectTypeViewModels model) { using (JournalContext db = new JournalContext()) { if (ModelState.IsValid) { SubjectType subjectType = db.SubjectTypes.Find(model.ID); subjectType.Name = model.Name; subjectType.Description = model.Description; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(model)); }
public ActionResult Create(SubjectTypeViewModels model) { using (JournalContext db = new JournalContext()) { if (ModelState.IsValid) { SubjectType subjectType = (SubjectType)model; subjectType.ID = Guid.NewGuid(); db.SubjectTypes.Add(subjectType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); } }
public ActionResult Edit(Guid id) { using (JournalContext db = new JournalContext()) { SubjectTypeViewModels model = new SubjectTypeViewModels(); SubjectType subjectType = db.SubjectTypes.Find(id); model.ID = subjectType.ID; model.Name = subjectType.Name; model.Description = subjectType.Description; if (subjectType == null) { return(HttpNotFound()); } return(View(model)); } }