//JSON data call for dropdown.... public JsonResult GetByDepartment(int?departmentId) { if (departmentId == null) { return(null); } var designation = _employeeDesignationManager.GetByDepartmentId((int)departmentId); return(Json(designation, JsonRequestBehavior.AllowGet)); }
// GET: Employees/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employee employee = _employeeManager.GetById((int)id); if (employee == null) { return(HttpNotFound()); } EmployeeViewModel employeeViewModel = Mapper.Map <EmployeeViewModel>(employee); ViewBag.DepartmentId = new SelectList(_departmentManager.GetAll(), "Id", "Name", employeeViewModel.DepartmentId); if (ViewBag.DepartmentId != null) { ViewBag.EmployeeDesignationId = new SelectList(_employeeDesignationManager.GetByDepartmentId(employeeViewModel.DepartmentId), "Id", "Designation", employeeViewModel.EmployeeDesignationId); } return(View(employeeViewModel)); }