Exemplo n.º 1
0
        public JsonResult GetDataPager(DataTableSearchModel searchInput)
        {
            if (searchInput.ActionType == "group_action")
            {
                if (string.IsNullOrEmpty(searchInput.CustomActionValue) || searchInput.id == null ||
                    searchInput.id.Count == 0)
                {
                    return(Json(new { actionType = searchInput.ActionType, customActionStatus = false, customActionMsg = "无效参数" }));
                }
                try
                {
                    _reportAppService.BatchUpdateStatusAsync(searchInput.id, bool.Parse(searchInput.CustomActionValue));
                    return(Json(new { actionType = searchInput.ActionType, customActionStatus = true, customActionMsg = "" }));
                }
                catch (Exception e)
                {
                    return(Json(new { actionType = searchInput.ActionType, customActionStatus = false, customActionMsg = "无效参数" }));
                }
            }


            int pageIndex = 0;

            GetReportInput defaultInput = new GetReportInput()
            {
                MaxResultCount = CarFactoryConsts.MaxPageSize,
                SkipCount      = pageIndex * CarFactoryConsts.MaxPageSize,
                Sorting        = "CreationTime",
                Page           = pageIndex + 1
            };

            if (searchInput != null && searchInput.ActionType == "filter")
            {
                defaultInput.Id         = searchInput.FilterId;
                defaultInput.BeginDate  = searchInput.FilterDateFrom;
                defaultInput.EndDate    = searchInput.FilterDateTo;
                defaultInput.FilterText = searchInput.FilterName ?? "";
                defaultInput.Status     = searchInput.FilterStatus;
            }


            var list = _reportAppService.GetPagedReportsAsync(defaultInput).Result;

            var pagedProducts = new StaticPagedList <ReportListDto>(list.Items, defaultInput.Page.Value, defaultInput.MaxResultCount,
                                                                    list.TotalCount);


            var viewModelList = GenerateTablePagerData(pagedProducts, "/admin/reports/detail/");

            return(Json(new { draw = Request.Form["draw"], recordsTotal = pagedProducts.TotalItemCount, recordsFiltered = pagedProducts.Count, data = viewModelList }, JsonRequestBehavior.AllowGet));
        }