Beispiel #1
0
        public async Task <IActionResult> GetFilms(int pageIndex = 0, PageSize pageSize = PageSize.PS10)
        {
            var user = await _userManager.GetUserAsync(this.User);

            var size   = (int)pageSize;
            var offset = pageIndex * size;
            var count  = await _repository.CountAsync();

            var model = new FilmsViewModel()
            {
                Films     = _repository.GetFilms(offset, size).Select(f => GetFilmViewModel(f, user, false)),
                PageIndex = pageIndex,
                PageCount = (int)Math.Ceiling((double)count / size),
                PageSize  = pageSize
            };

            return(View("Films", model));
        }