public ActionResult Create(DepartmentViewModel dvm) { if (ModelState.IsValid) { var department = new CYBInfracstructure.DataStructure.Entities.Department { DepartmentName = dvm.DepartmentName, IsActive = dvm.IsActive, LocationId = dvm.LocationId, Date = dvm.Date }; _department.Add(department); _department.SaveChanges(); //return Json(new { success = true, messsage = "Saved Successfully" }, JsonRequestBehavior.AllowGet); //FlashMessage.Confirmation("You have been logged in as: {0}"); TempData["Success"] = "Added Successfully!"; return(RedirectToAction("Index")); } var locations = locationManager.GetAll().ToList(); DepartmentViewModel departmentModel = new DepartmentViewModel { Locations = locations }; return(View(departmentModel)); }
public ActionResult Delete(int id) { CYBInfracstructure.DataStructure.Entities.Department department = _department.Find(x => x.Id == id).FirstOrDefault(); _department.Remove(department); _department.SaveChanges(); TempData["Success"] = "Deleted Successfully!"; return(RedirectToAction("Index")); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CYBInfracstructure.DataStructure.Entities.Department department = _department.Find(x => x.Id == id).FirstOrDefault(); ViewBag.locations = locationManager.GetAll(); if (department == null) { return(HttpNotFound()); } return(View(department)); }
public ActionResult Edit(DepartmentViewModel dvm) { var dept = new CYBInfracstructure.DataStructure.Entities.Department { DepartmentName = dvm.DepartmentName, Id = dvm.Id, LocationId = dvm.LocationId, IsActive = dvm.IsActive, Date = dvm.Date }; if (TryUpdateModel(dept)) { _department.Edit(dept); _department.SaveChanges(); TempData["Success"] = "Edited Successfully!"; //TempData["Message"] = "Client Details Edited Successfully"; return(RedirectToAction("Index")); } return(View()); }
public ActionResult Details(int?id) { CYBInfracstructure.DataStructure.Entities.Department department = _department.Find(x => x.Id == id).FirstOrDefault(); return(View(department)); }