示例#1
0
        public async Task <IActionResult> Year(int page = 1)
        {
            var films = dBContext.Films.Include(e => e.Reting)
                        .Include(e => e.Year).Include(e => e.FilmsToCountrys).ThenInclude(e => e.Country)
                        .Where(e => e.Year.Year.ToString() == RouteData.Values["Id"].ToString()).ToList();

            ListFilmModel model = new ListFilmModel();

            foreach (var i in films)
            {
                model.ListFilms.Add(new ListFilm()
                {
                    Id      = i.Id,
                    Name    = i.Name,
                    Photo   = i.Photo,
                    Star    = i.Reting.AllStar,
                    Year    = i.Year.Year,
                    Country = i.FilmsToCountrys.Where(e => e.FilmId == i.Id).FirstOrDefault().Country.Name
                });
            }

            var count = model.ListFilms.Count();
            var items = model.ListFilms.Skip((page - 1) * pageSize).Take(pageSize).ToList();

            PageViewModel pageViewModel = new PageViewModel(count, page, pageSize);

            model.PageViewModel = pageViewModel;
            model.ListFilms     = items;

            return(View("Index", model));
        }
示例#2
0
        public IActionResult Index(int page = 1)
        {
            var           db    = dBContext.Films.Include(e => e.Reting).Include(e => e.Year).Include(e => e.FilmsToCountrys).ThenInclude(e => e.Country);
            ListFilmModel model = new ListFilmModel();

            foreach (var i in db)
            {
                model.ListFilms.Add(new ListFilm()
                {
                    Id      = i.Id,
                    Name    = i.Name,
                    Photo   = i.Photo,
                    Star    = i.Reting.AllStar,
                    Year    = i.Year.Year,
                    Country = i.FilmsToCountrys.Where(e => e.FilmId == i.Id).FirstOrDefault().Country.Name
                });
            }


            var count = model.ListFilms.Count();
            var items = model.ListFilms.Skip((page - 1) * pageSize).Take(pageSize).ToList();

            PageViewModel pageViewModel = new PageViewModel(count, page, pageSize);

            model.PageViewModel = pageViewModel;
            model.ListFilms     = items;

            return(View(model));
        }