private string getWhileLoopDataDepartment()
        {
            DepartmentManager departmentManager = new DepartmentManager();


            List <Department> empty = new List <Department>();

            empty = departmentManager.GetChildItems(departmentManager.Read(null).First().Id, empty);
            htmlStr2.Append("[{id:\"");
            htmlStr2.Append(departmentManager.Read(null).First().Id);
            htmlStr2.Append("\",text: \"");
            htmlStr2.Append(departmentManager.Read(null).First().Name);
            htmlStr2.Append("\",expanded: true,spriteCssClass: \"rootfolder\"");
            //Check if there is any children or not
            if (GetRowsByParentDep(departmentManager.Read(null).First().Id).Count > 0)
            {
                htmlStr2.Append(",items: [");
                //Les go inside Childs
                GetChildItems(departmentManager.Read(null).First().Id, new List <Department>());
                //End tag
                htmlStr2.Append("]");
            }

            htmlStr2.Append("}]");
            return(htmlStr2.ToString());
        }
        public ActionResult GetEmployees(List <Guid> idList, Guid?postGuid, bool noPost)
        {
            if (idList != null && idList.Count > 0)
            {
                if (!noPost)
                {
                    DepartmentManager departmentManager  = new DepartmentManager();
                    List <Department> checkedDepartments = new List <Department>();
                    foreach (var id in idList)
                    {
                        checkedDepartments.Add(departmentManager.Read(id));
                        //checkedOrganizations.AddRange(organizationManager.GetChildItems(id, new List<Organization>()));
                    }
                    EmployeeManager employeeManager = new EmployeeManager();
                    List <Employee> employeeList    = new List <Employee>();
                    //Remove non organized people from json
                    //peopleList.AddRange(usermanager.GetUserShowablePeopleList(usermanager.Read(new Guid(User.Identity.Name))));
                    foreach (var department in checkedDepartments.Distinct())
                    {
                        employeeList.AddRange(employeeManager.GetDepartmentEmployees(department, postGuid));
                    }

                    return(Json(employeeList.Distinct().ToList().Select(x => new { x.Id, x.FirstName, x.LastName })));
                }
                else
                {
                    DepartmentManager departmentManager  = new DepartmentManager();
                    List <Department> checkedDepartments = new List <Department>();
                    foreach (var id in idList)
                    {
                        checkedDepartments.Add(departmentManager.Read(id));
                        checkedDepartments.AddRange(departmentManager.GetChildItems(id, new List <Department>()));
                    }
                    EmployeeManager employeeManager = new EmployeeManager();

                    List <Tuple <Employee, Post, Department> > peopleList = (from department in checkedDepartments.Distinct() from item in employeeManager.GetDepartmentEmployees(department) select new Tuple <Employee, Post, Department>(item.Item1, item.Item2, item.Item3)).ToList();

                    return(Json(peopleList.Select(x => new { x.Item1.Id, x.Item1.FirstName, x.Item1.LastName, x.Item2.Name, postID = x.Item2.Id, departmentName = x.Item3.GetFullDepartmentPath(), departmentID = x.Item3.Id })));
                }
            }
            else
            {
                EmployeeManager employeeManager = new EmployeeManager();
                return(Json(employeeManager.NoneDepartment().Select(x => new { x.Id, x.FirstName, x.LastName })));
            }
        }