public ActionResult Details(int?id) { DepartmentDBHelper db = new DepartmentDBHelper(); Department dept = db.GetDepartments().FirstOrDefault(d => d.Id == id); return(View(dept)); }
public ActionResult DeletePost(int?id) { try { DepartmentDBHelper db = new DepartmentDBHelper(); db.DeleteDepartment(id); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public ActionResult Create(string Name, string Location) { try { Department d = new Department() { Name = Name, Location = Location }; DepartmentDBHelper db = new DepartmentDBHelper(); db.InsertDepartment(d); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public ActionResult Edit() { if (ModelState.IsValid) { Department d = new Department(); TryUpdateModel <Department>(d); try { DepartmentDBHelper db = new DepartmentDBHelper(); db.UpdateDepartment(d); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } } else { return(View()); } }
public ViewResult Index() { DepartmentDBHelper db = new DepartmentDBHelper(); return(View(db.GetDepartments().ToString())); }