private async Task LoadViewModelProperties(PagedPopularAnimeSeriesViewModel viewModel, int page) { int pagesToLoad = (int)Math.Ceiling((double)await this.AnimeService.GetAllAnimesSeriesCountAsync() / NumericConstants.Number_Of_Animes_Per_Page); if (page > pagesToLoad) { page = pagesToLoad; } viewModel.Animes = await this.AnimeService.GetPopularAnimesSeriesForPage(page, true); viewModel.Pagination.Pages = this.AnimeService.LoadPages(page, pagesToLoad); viewModel.Pagination.PageUrl = UrlConstants.Popular_Pagination; viewModel.Pagination.CurrentPage = page; }
public async Task <IActionResult> Popular(int?id) { PagedPopularAnimeSeriesViewModel viewModel = new PagedPopularAnimeSeriesViewModel(); if (id.HasValue && id > 0) { await this.LoadViewModelProperties(viewModel, id.Value); } else { await this.LoadViewModelProperties(viewModel, 1); } return(this.View(viewModel)); }