Exemple #1
0
        public virtual IActionResult DepartmentList(DepartmentSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageServices))
            {
                return(AccessDeniedKendoGridJson());
            }
            //prepare model
            var model = _departmentModelFactory.PrepareListModel(searchModel);

            return(Json(model));
        }
Exemple #2
0
        public ActionResult Index(int?page)
        {
            int pageIndex                       = PagingHelper.GetPageIndex(page);
            DepartmentSearchModel   q           = new DepartmentSearchModel();
            IPagedList <Department> departments = departmentService.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            SetCompanyList(null);

            return(View(departments));
        }
        public IActionResult List()
        {
            if (!_permissionService.Authorize(EmployeePermissionProvider.ManageDepartments))
            {
                return(AccessDeniedView());
            }

            var model = new DepartmentSearchModel();

            model.SetGridPageSize();
            return(View($"{Route}{nameof(List)}.cshtml", model));
        }
Exemple #4
0
        public virtual DepartmentSearchModel PrepareSearchModel(DepartmentSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
        public async Task <DepartmentListModel> GetByPaging(DepartmentSearchModel request)
        {
            try
            {
                var start = 1;

                if (request != null)
                {
                    start = request.Start / request.Length + 1;
                }

                var columnOrder = "name";
                var sortDir     = "ASC";

                var url = string.Format(ApiUrl.DEPARTMENT_GET_BY_PAGING,
                                        request.Name,
                                        request.ColumnOrder,
                                        start,
                                        request?.Length ?? 10,
                                        columnOrder,
                                        sortDir);

                var response = await HttpService.Send <PageResult <GetDepartmentPagingResponse> >(url,
                                                                                                  null,
                                                                                                  HttpMethod.Get,
                                                                                                  true);

                if (response.IsSuccess)
                {
                    return new DepartmentListModel
                           {
                               Draw            = request.Draw,
                               RecordsFiltered = response.Data.TotalCount,
                               Total           = response.Data.TotalCount,
                               RecordsTotal    = response.Data.TotalCount,
                               Data            = response.Data.Data.Select(c => new DepartmentModel
                        {
                            Id              = c.Id,
                            Name            = c.Name,
                            PageSize        = request.PageSize,
                            PageSizeOptions = request.AvailablePageSizes
                        })
                           }
                }
                ;

                throw new PeloException(response.Message);
            }
            catch (Exception exception)
            {
                throw new PeloException(exception.Message);
            }
        }
Exemple #6
0
        public virtual DepartmentListModel PrepareListModel(DepartmentSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }
            var entities = _departmentService.GetAll(name: searchModel.SearchName,
                                                     pageIndex: searchModel.Page - 1,
                                                     pageSize: searchModel.PageSize,
                                                     showHidden: true);

            //Get follow Path
            foreach (var template in entities)
            {
                var templateName = "";
                if (template.Path != string.Empty)
                {
                    var        listPath    = template.Path.Split(",").ToList();
                    List <int> listPathInt = listPath.Select(s => int.Parse(s)).ToList();
                    foreach (var listPathItem in listPathInt)
                    {
                        foreach (var templateItem in entities)
                        {
                            if (listPathItem == templateItem.Id)
                            {
                                templateName += templateItem.Name + " >> ";
                            }
                        }
                    }
                }
                if (templateName != string.Empty)
                {
                    templateName = templateName + template.Name;
                }
                else
                {
                    templateName = template.Name;
                }
                template.PathName = templateName;
            }

            //prepare list model
            var model = new DepartmentListModel
            {
                //fill in model values from the entity
                Data  = entities.Select(x => x.ToModel <DepartmentModel>()),
                Total = entities.Count
            };

            return(model);
        }
Exemple #7
0
        public IQueryable <Department> Search(DepartmentSearchModel searchModel)
        {
            IQueryable <Department> departments = this.context.Department;

            if (!string.IsNullOrEmpty(searchModel.Name))
            {
                departments = departments.Where(c => c.name.Contains(searchModel.Name.Trim()));
            }

            if (searchModel.CompanyId.HasValue)
            {
                departments = departments.Where(c => c.companyId.Equals(searchModel.CompanyId));
            }
            return(departments);
        }
 public IHttpActionResult QueryDepartment(DepartmentSearchModel search)
 {
     try
     {
         if (search == null)
         {
             return(BadRequest());
         }
         if (search.PageIndex == 0)
         {
             search.PageIndex = 1;
         }
         if (search.PageSize == 0)
         {
             search.PageSize = 20;
         }
         if (!UserController.LoginDictionary.ContainsKey(GetCookie("token")))
         {
             return(Logout());
         }
         UserInfo userCookie = UserController.LoginDictionary[GetCookie("token")];
         if (userCookie == null)
         {
             return(Logout());
         }
         List <Department> departList = Department.GetAllChildren(userCookie.DepartmentID);
         if (!string.IsNullOrEmpty(search.DepartmentName))
         {
             departList.FindAll(m => m.Name.Contains(search.DepartmentName));
         }
         var result = Department.GetDepartment(search, departList.Select(m => m.ID).ToList());
         if (result.Items.Count > 0)
         {
             var list = Department.GetAll(result.Items.ToList().Select(m => m.ID).ToList());
             result.Items.ForEach(item =>
             {
                 item.ParentName = list.Find(m => m.ID == item.ParentID)?.Name;
             });
         }
         return(Success(result));
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         return(Failure("查询失败"));
     }
 }
Exemple #9
0
        public ActionResult Search([Bind(Include = "Name, CompanyId")] DepartmentSearchModel q)
        {
            int pageIndex = 0;

            int.TryParse(Request.QueryString.Get("page"), out pageIndex);
            pageIndex = PagingHelper.GetPageIndex(pageIndex);

            IDepartmentService ds = new DepartmentService(Settings.Default.db);

            IPagedList <Department> departments = ds.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            SetCompanyList(q.CompanyId);

            return(View("Index", departments));
        }
Exemple #10
0
        public static Page <DepartmentA> GetDepartment(DepartmentSearchModel search, List <int> depart)
        {
            var        sql    = "select * from Department where ID in @ID ";
            List <int> IDList = new List <int>();

            if ((search.ParentID ?? 0) != 0)
            {
                IDList = GetChildrenID(new List <int> {
                    search.ParentID.Value
                });
                sql += " and ParentID in @IDs";
            }

            using (var cn = Database.GetDbConnection())
            {
                return(cn.PagedQuery <DepartmentA>(search.PageIndex, search.PageSize, sql, new { IDs = IDList, ID = depart }));
            }
        }
        public IActionResult ListData(DepartmentSearchModel searchModel)
        {
            if (!_permissionService.Authorize(EmployeePermissionProvider.ManageDepartments))
            {
                return(AccessDeniedView());
            }

            var departments = _employeeService.GetOrderedDepartments(showUnpublished: true, searchModel.Page - 1, searchModel.PageSize);
            var model       = new DepartmentListModel().PrepareToGrid(searchModel, departments, () =>
            {
                return(departments.Select(department =>
                {
                    var d = department.ToModel();
                    return d;
                }));
            });

            return(Json(model));
        }
Exemple #12
0
        public IActionResult ListData(DepartmentSearchModel searchModel)
        {
            if (!_permissionService.Authorize(EmployeePermissionProvider.ManageEmployees))
            {
                return(AccessDeniedView());
            }

            var departmentDict = _employeeService.GetOrderedDepartments(showUnpublished: true).ToDictionary(x => x.Id, x => x);

            var employees = _employeeService.GetOrderedEmployees(showUnpublished: true, searchModel.Page - 1, searchModel.PageSize);
            var model     = new EmployeeListModel().PrepareToGrid(searchModel, employees, () =>
            {
                return(employees.Select(employee =>
                {
                    var e = employee.ToModel();
                    e.DepartmentName = departmentDict[e.DepartmentId].Name;
                    e.DepartmentPublished = departmentDict[e.DepartmentId].Published;
                    return e;
                }));
            });

            return(Json(model));
        }
Exemple #13
0
 public IQueryable <Department> Search(DepartmentSearchModel searchModel)
 {
     return(depRep.Search(searchModel));
 }