예제 #1
0
        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));
        }
예제 #2
0
        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"));
        }
예제 #3
0
 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));
 }
예제 #4
0
        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());
        }
예제 #5
0
 public ActionResult Details(int?id)
 {
     CYBInfracstructure.DataStructure.Entities.Department department = _department.Find(x => x.Id == id).FirstOrDefault();
     return(View(department));
 }