Пример #1
0
        public ViewResult List(ReportsGridDTO values)
        {
            var builder = new ReportsGridBuilder(HttpContext.Session, values, defaultSortField: nameof(Report.Date));

            builder.SetSearchRoute(values.SearchString);

            builder.SaveRouteSegments();

            var options = new ReportQueryOptions
            {
                Includes         = "ReportType",
                OrderByDirection = builder.CurrentRoute.SortDirection,
                PageNumber       = builder.CurrentRoute.PageNumber,
                PageSize         = builder.CurrentRoute.PageSize
            };

            options.SortFilter(builder);

            var model = new ReportListViewModel
            {
                Reports     = _data.List(options),
                ReportTypes = _reportType.List(new QueryOptions <ReportType>
                {
                    OrderBy = rt => rt.Name
                }),
                CurrentRoute = builder.CurrentRoute,
                TotalPages   = builder.GetTotalPages(_data.Count)
            };

            return(View(model));
        }