public HttpResponseMessage GetAllManagerDepartmentTreeByMelliCode(string code)
        {
            try
            {
                var person = PersonBusinesss.GetByBarcode(code);
                if (person == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new List <TreeItem>()));
                }

                decimal managerPersonId = person.ID;

                var manager = ManagerBusiness.GetManager(managerPersonId);
                IList <Department> departments = DepartmentBusiness.GetAllManagerDepartmentTree_JustOrgan(manager.ID);

                var result = departments.Select(c => new TreeItem()
                {
                    id = (Int32)c.ID, parentid = (Int32)c.ParentID, text = c.Name
                }).ToList();
                return(Request.CreateResponse(HttpStatusCode.OK, result));
            }
            catch (UIValidationExceptions ex)
            {
                this.exceptionHandler.ApiHandleException("DepartmentController", ex);
                return(Request.CreateResponse(HttpStatusCode.NotFound, ex.ExceptionList.Count > 0 ? ex.ExceptionList[0].Message : ex.Message));
            }
            catch (Exception ex)
            {
                this.exceptionHandler.ApiHandleException("DepartmentController", ex);
                return(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message));
            }
        }
        public IList <TreeItem> GetAllManagerDepartmentTree(decimal id)
        {
            try
            {
                decimal managerPersonId;
                if (id == 0)
                {
                    managerPersonId = BUser.CurrentUser.Person.ID;
                }
                else
                {
                    managerPersonId = id;
                }

                var manager = ManagerBusiness.GetManager(managerPersonId);
                IList <Department> departments = DepartmentBusiness.GetAllManagerDepartmentTree_JustOrgan(manager.ID);
                return(departments.Select(c => new TreeItem()
                {
                    id = (Int32)c.ID, parentid = (Int32)c.ParentID, text = c.Name
                }).ToList());
            }
            catch (Exception ex)
            {
                this.exceptionHandler.ApiHandleException("OverTimePersonController", ex);
                return(new List <TreeItem>());
            }
        }