public async Task <IActionResult> TheatrePages(int?currPage, string sortOrder)
        {
            try
            {
                var currentPage = currPage ?? 1;
                var totalPages  = await _theatreServices.GetPageCountAsync(5);

                var sixTheatres = await _theatreServices.GetSixTheatresAsync(currentPage, sortOrder);

                var convertedTheatre = _theatreViewModelMapper.MapFrom(sixTheatres);

                var model = new TheatreIndexViewModel()
                {
                    CurrPage      = currentPage,
                    TotalPages    = totalPages,
                    TheatreModels = convertedTheatre,
                };

                if (totalPages > currentPage)
                {
                    model.NextPage = currentPage + 1;
                }

                if (currentPage > 1)
                {
                    model.PrevPage = currentPage - 1;
                }
                return(PartialView("_TheatreIndexTable", model));
            }
            catch (Exception)
            {
                //_logger.LogError("Something went wrong");
                return(RedirectToAction(nameof(Index)));
            }
        }
        public static TheatreIndexViewModel MapFromTheatreIndex(this ICollection <TheatreViewModel> theatre)
        {
            var model = new TheatreIndexViewModel
            {
                TheatreModels = theatre
            };

            return(model);
        }
        public static TheatreIndexViewModel MapFromEmailIndex(this ICollection <TheatreViewModel> theatres, int currentPage, int totalPages)
        {
            var model = new TheatreIndexViewModel
            {
                CurrPage      = currentPage,
                TotalPages    = totalPages,
                TheatreModels = theatres
            };

            return(model);
        }
Exemple #4
0
        public async Task <IActionResult> Index()
        {
            var toptheatresVM = (await CacheTopTheatres())
                                .Select(x => _theatreVmMapper.MapFrom(x))
                                .ToList();

            var homeViewModel = new TheatreIndexViewModel
            {
                TheatreModels = toptheatresVM
            };

            return(View(homeViewModel));
        }