public JsonResult setRep(int empId) { object status; int userid = EmployeeData.GetId((string)Session["username"]); if (userid == empId) { status = new { status = false }; return(Json(status, JsonRequestBehavior.AllowGet)); } Department dep = DepartmentData.GetDepById(EmployeeData.FindEmpById(userid).department.Id); Employee currentRep = EmployeeData.FindEmpById(dep.DepRepId); Employee newRep = EmployeeData.FindEmpById(empId); EmployeeData.SetRoleToEmp(currentRep.Id); EmployeeData.SetRoleToRep(newRep.Id); DepartmentData.SetRep(EmployeeData.FindEmpById(userid).department.Id, empId); status = new { status = true }; return(Json(status, JsonRequestBehavior.AllowGet)); }