예제 #1
0
        public async Task <IActionResult> Kits(int page = 1)
        {
            var settings = await _performerSchedulingService.GetSettingsAsync();

            var schedulingStage = _performerSchedulingService.GetSchedulingStage(settings);

            if (schedulingStage < PsSchedulingStage.SchedulingPreview)
            {
                return(RedirectToAction(nameof(Index)));
            }

            var filter = new BaseFilter(page, KitsPerPage);

            var kitList = await _performerSchedulingService.GetPaginatedKitListAsync(filter);

            var paginateModel = new PaginateViewModel
            {
                ItemCount    = kitList.Count,
                CurrentPage  = page,
                ItemsPerPage = filter.Take.Value
            };

            if (paginateModel.PastMaxPage)
            {
                return(RedirectToRoute(
                           new
                {
                    page = paginateModel.LastPage ?? 1
                }));
            }

            var viewModel = new KitListViewModel
            {
                Kits          = kitList.Data,
                PaginateModel = paginateModel
            };

            return(View(viewModel));
        }