Пример #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));
        }
Пример #2
0
        public RedirectToActionResult Index(ReportsGridDTO values)
        {
            // This code block makes sure the current route is always set
            var builder = new ReportsGridBuilder(HttpContext.Session, values, defaultSortField: nameof(Report.Date));

            builder.SetSearchRoute(values.SearchString);

            return(RedirectToAction("List", "Home", builder.CurrentRoute));
        }
Пример #3
0
        public RedirectToActionResult Filter(string[] filter, ReportsGridDTO values, bool clear = false)
        {
            // Added the ReportsGridDTO object above to pull the current search string
            var builder = new ReportsGridBuilder(HttpContext.Session);

            if (clear)
            {
                builder.ClearFilterSegments();
                builder.SetSearchRoute(null);
            }
            else
            {
                var reportTypes = _reportType.Get(filter[0].ToInt());
                builder.LoadFilterSegments(filter, reportTypes);
                builder.SetSearchRoute(values.SearchString);
            }
            builder.SaveRouteSegments();

            return(RedirectToAction("List", builder.CurrentRoute));
        }