public ActionResult Create([Bind(Include = "Id,Name,CampusCode")] Campus campus) { if (ModelState.IsValid) { db.Campuses.Add(campus); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(campus)); }
public ActionResult Create(DepartmentViewModel model) { if (ModelState.IsValid) { Department dept = new Department(); dept.Name = model.Name; dept.DeptCode = model.DeptCode; dept.CampusId = model.CampusId; db.Departments.Add(dept); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CampusList = db.Campuses.ToList(); return(View(model)); }
public ActionResult Create(ContractorViewModel model) { if (ModelState.IsValid) { Contractor cont = new Contractor(); cont.Name = model.Name; cont.Phone = model.Phone; cont.Email = model.Email; cont.Address = model.Address; cont.DeptId = model.DeptId; cont.Status = model.Status; db.Contractors.Add(cont); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartmentsList = db.Departments.ToList(); return(View(model)); }