public ActionResult Delete(int?id) { DeparmentDBHelper db = new DeparmentDBHelper(); Department dept = db.GetDepartments().FirstOrDefault(d => d.Id == id); return(View(dept)); }
public ActionResult Delete(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Id Required")); } DeparmentDBHelper db = new DeparmentDBHelper(); db.DeleteDeptDetails(id); return(RedirectToAction("Index")); }
public ActionResult create(string Name, string Location) { try { Department d = new Department() { Name = Name, Location = Location }; DeparmentDBHelper db = new DeparmentDBHelper(); db.InsertDeptDetails(d); return(RedirectToAction("Index")); } catch (Exception) { return(View()); } }
public ActionResult Edit(string Id, string Name, string Location) { try { Department d = new Department() { Id = Convert.ToInt32(Id), Name = Name, Location = Location }; DeparmentDBHelper db = new DeparmentDBHelper(); db.UpdateDeptDetails(d); return(RedirectToAction("Index")); } catch (Exception) { return(View()); } }
public ActionResult Index() { DeparmentDBHelper db = new DeparmentDBHelper(); return(View(db.GetDepartments().ToList())); }