コード例 #1
0
        public ActionResult Index(string sortOrder, string searchString, string searchSelection, string currentFilter, string currentSelection, int?page, int?pageSize)
        {
            ViewBag.CurrentSort = sortOrder;

            ViewBag.NameSortParm     = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewBag.LoginSortParm    = sortOrder == "Login" ? "Login_desc" : "Login";
            ViewBag.PositionSortParm = sortOrder == "Position" ? "Position_desc" : "Position";
            ViewBag.RoleSortParm     = sortOrder == "Role" ? "Role_desc" : "Role";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString    = currentFilter;
                searchSelection = currentSelection;
            }

            ViewBag.CurrentFilter    = searchString;
            ViewBag.CurrentSelection = searchSelection;
            ViewBag.CurrentPageSize  = pageSize;

            int currentPage = (page ?? 1);

            pageSize = (pageSize ?? 5);
            StaticPagedList <UserDTO> usersDTOPaged = userService.GetPagedUsers(sortOrder, searchString, searchSelection, currentPage, pageSize);

            Mapper.Initialize(cfg => cfg.CreateMap <UserDTO, UserViewModel>());
            var users      = Mapper.Map <IEnumerable <UserDTO>, IEnumerable <UserViewModel> >(usersDTOPaged);
            var usersPaged = new StaticPagedList <UserViewModel>(users, usersDTOPaged.GetMetaData());

            return(View(usersPaged));
        }
コード例 #2
0
        public async Task <HttpResponseMessage> GetEventsAsync([FromUri] FilterModel filter)
        {
            if (filter.EndTime <= DateTime.Now && filter.StartTime == null)
            {
                filter.StartTime = DateTime.MinValue;
            }

            if (filter.EndTime == null)
            {
                filter.EndTime = DateTime.MaxValue;
            }

            if (filter.StartTime == null && filter.EndTime > DateTime.Now)
            {
                filter.StartTime = DateTime.Now;
            }

            var result = await Service.GetEventsAsync(filter);

            var temp = Mapper.Map <IEnumerable <IEvent>, IEnumerable <EventModel> >(result);

            var responseData = new StaticPagedList <EventModel>(temp, result.GetMetaData());

            var response = new { data = responseData, metaData = responseData.GetMetaData() };

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #3
0
        public ActionResult AjaxPage(int?page)
        {
            int pageIndex           = page ?? 1;
            int pageSize            = 1;
            int totalCount          = 0;
            var sysUsers            = GetsysUsers(pageIndex, pageSize, ref totalCount);
            var sysUsersAsIPageList = new StaticPagedList <SysUser>(sysUsers, pageIndex, pageSize, totalCount);

            return(Json(new { sysUsers = sysUsersAsIPageList, pager = sysUsersAsIPageList.GetMetaData() }, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public async Task <IActionResult> Paginate([FromQuery] PageOption pageOption, [FromQuery] string session = "")
        {
            IPagedList <Model> pagedData = await repository.PaginateAsync(pageOption);

            IEnumerable <ModelResponse> pageContents = mapper.Map <IEnumerable <ModelResponse> >(pagedData);

            IPagedList <ModelResponse> page = new StaticPagedList <ModelResponse>(pageContents, pagedData.GetMetaData());

            return(Ok(new PagedDataResponse {
                Data = page, MetaData = page.GetMetaData()
            }));
        }
コード例 #5
0
        public ActionResult AjaxPage(int?page)
        {
            //具体的页面数
            int pageIndex = page ?? 1;
            //页面显示条数
            int pageSize = Request["pageSize"] == null ? 10 : Convert.ToInt32(Request["pageSize"]);
            // 数据记录条数
            int totalCount            = 0;
            List <Models.Person> list = new OrginPager.BLL.PersonService().GetAllPerson(pageSize, pageIndex, "", out totalCount);
            var personsAsIPageList    = new StaticPagedList <Person>(list, pageIndex, pageSize, totalCount);

            return(Json(new { persons = personsAsIPageList, pager = personsAsIPageList.GetMetaData() }, JsonRequestBehavior.AllowGet));
        }