public ActionResult AddClass() { ViewBag.TitleName = "Add Class"; var days = new AddClassForm(); return(View(days)); }
public ActionResult EditClass(int id) { ViewBag.TitleName = "Edit Class"; var Class = _context.Classes.SingleOrDefault(c => c.Id == id); if (Class == null) { return(HttpNotFound()); } else { var viewModel = new AddClassForm { Class = Class }; return(View("AddClass", viewModel)); } }
public ActionResult Save(AddClassForm classes) { if (classes.Class.Id == 0) { _context.Classes.Add(classes.Class); } else { var classInDb = _context.Classes.Single(c => c.Id == classes.Class.Id); classInDb.Name = classes.Class.Name; classInDb.Day = classes.Class.Day; classInDb.StartTime = classes.Class.StartTime; } _context.SaveChanges(); return(RedirectToAction("Index", "Classes")); }
private void buttonAddClass_Click(object sender, EventArgs e) { AddClassForm newForm = new AddClassForm(currentCharacter); newForm.Show(); }