Esempio n. 1
0
        public EventAllViewModel All()
        {
            var events = context.Events.Where(e => e.TotalTickets > 0)
                         .Select(x => new EventViewModel
            {
                End = x.End,
                TicketsRemaining = x.TotalTickets,
                Start            = x.Start,
                Name             = x.Name
            })
                         .ToArray();

            for (int i = 0; i < events.Length; i++)
            {
                events[i].Number = i + 1;
            }

            var eventAllViewModel = new EventAllViewModel
            {
                Events = events
            };

            if (eventAllViewModel.Events.Count() % Constants.EventsPageListCount == 0)
            {
                eventAllViewModel.TotalPages = eventAllViewModel.Events.Count() / Constants.EventsPageListCount;
            }
            else
            {
                eventAllViewModel.TotalPages = eventAllViewModel.Events.Count() / Constants.EventsPageListCount + 1;
            }

            return(eventAllViewModel);
        }
Esempio n. 2
0
        public IActionResult All()
        {
            var viewModel = new EventAllViewModel()
            {
                Events =
                    this.eventsService.GetAll <EventSingleViewModel>(),
            };

            return(this.View(viewModel));
        }