Exemplo n.º 1
0
        public ActionResult AdminLoggerListProvide(AdminLoggerDTO adminLoggerDTO)
        {
            if (!base.HasPermission("adminlogger", PermissionOperate.manager))
            {
                return(null);
            }

            PagedList <AdminLogger> list = _adminLoggerService.GetPageList(PageIndex, PageSize, adminLoggerDTO);

            return(JsonList <AdminLogger>(list, list.TotalItemCount));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据搜索条件获取分页数据
        /// </summary>
        public PagedList <AdminLogger> GetPageList(int pageIndex, int pageSize, AdminLoggerDTO adminLoggerDTO)
        {
            IQueryable <AdminLogger> query = base.Table;

            if (adminLoggerDTO.StartDate.HasValue)
            {
                query = query.Where(l => l.CreateDate >= adminLoggerDTO.StartDate);
            }

            if (adminLoggerDTO.EndDate.HasValue)
            {
                query = query.Where(l => l.CreateDate <= ((DateTime)adminLoggerDTO.EndDate).AddDays(1));
            }

            if (!string.IsNullOrWhiteSpace(adminLoggerDTO.AdminName))
            {
                query = query.Where(l => l.AdminName == adminLoggerDTO.AdminName);
            }

            if (adminLoggerDTO.Module.HasValue)
            {
                query = query.Where(l => l.Module == adminLoggerDTO.Module);
            }

            query = query.OrderByDescending("CreateDate");
            int count = query.Count();

            if (pageIndex == 1)
            {
                query = query.Take <AdminLogger>(pageSize);
            }
            else
            {
                query = query.Skip <AdminLogger>((pageIndex - 1) * pageSize).Take <AdminLogger>(pageSize);
            }

            PagedList <AdminLogger> pageItems = new PagedList <AdminLogger>(query.ToList(), pageIndex, pageSize);

            pageItems.TotalItemCount = count;
            return(pageItems);
        }