Example #1
0
        public IActionResult Index([FromServices] EventsContext eventsContext, [FromServices] IOptions <ApplicationSettings> appSettings, int?page)
        {
            //var pagedEvents = Enumerable.Empty<Event>();

            int currentPage = page ?? 1;
            int totalRows   = eventsContext.Events.Count();
            int pageSize    = appSettings.Value.GridPageSize;
            var pagedEvents = eventsContext.Events
                              .OrderByDescending(e => e.StartTime)
                              .Skip(pageSize * (currentPage - 1))
                              .Take(pageSize);

            // EventsGridViewModel viewModel = new EventsGridViewModel
            // {
            //     CurrentPage = 0,
            //     PageSize = 0,
            //     TotalRows = 0,
            //     Events = pagedEvents
            // };

            EventsGridViewModel viewModel = new EventsGridViewModel
            {
                CurrentPage = currentPage,
                PageSize    = pageSize,
                TotalRows   = totalRows,
                Events      = pagedEvents
            };

            return(View(viewModel));
        }
Example #2
0
        public ActionResult Events(int?id)
        {
            EventsGridViewModel viewModel = new EventsGridViewModel(
                pageSize: EVENTS_GRID_SIZE,
                currentPage: id ?? 1
                );

            return(View(viewModel));
        }
Example #3
0
        public IActionResult Index([FromServices] EventsContext eventsContext, [FromServices] IOptions <ApplicationSettings> appSettings, int?page)
        {
            var pagedEvents = Enumerable.Empty <Event>();

            EventsGridViewModel viewModel = new EventsGridViewModel
            {
                CurrentPage = 0,
                PageSize    = 0,
                TotalRows   = 0,
                Events      = pagedEvents
            };

            return(View(viewModel));
        }
Example #4
0
        public ActionResult Events(string ipaddress)
        {
            IPAddress server;

            if (IPAddress.TryParse(ipaddress, out server))
            {
                EventsGridViewModel viewModel = new EventsGridViewModel(server);

                return(View("Events", viewModel));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }