Esempio n. 1
0
        public PartialViewResult Edit(int id)
        {
            var Employee = _db.Employees.Single(e => e.Id == id);

            var EmployeeEdit = new EditEmployeeViewModel();
            EmployeeEdit.Id = Employee.Id;
            EmployeeEdit.DepartmentId = Employee.Department.Id;
            EmployeeEdit.Name = Employee.Name;
            EmployeeEdit.HireDate = Employee.HireDate;
            return PartialView("_EditEmployeePartial", EmployeeEdit);
        }
Esempio n. 2
0
 public JsonResult Edit(EditEmployeeViewModel employee)
 {
     ModelState.Clear();
     if (ModelState.IsValid)
     {
         var EmployeeToUpdate = _db.Employees.Single(e => e.Id == employee.Id);
         EmployeeToUpdate.Name = employee.Name;
         _db.EntryChanged(EmployeeToUpdate);
         _db.Save();
         return Json(JsonResponseFactory.SuccessResponse(), JsonRequestBehavior.DenyGet);
     }
     return Json(JsonResponseFactory.ErrorResponse("Please review your form."), JsonRequestBehavior.DenyGet);
 }