Ejemplo n.º 1
0
        //[OutputCache(CacheProfile = "Short", Location = OutputCacheLocation.Server, VaryByHeader = "Accept-Language")]
        public ActionResult Index(string SearchQuery = null, int page = 1)
        {
            var model = _movieDb.Query <Movie>()
                        .OrderByDescending(m => m.reviews.Count())
                        .Where(m => SearchQuery == null || m.MovieName.StartsWith(SearchQuery))
                        .Select(m => new MovieViewModel
            {
                Id           = m.Id,
                MovieName    = m.MovieName,
                DirectorName = m.DirectorName,
                ReleaseYear  = m.ReleaseYear,
                NoOfReviews  = m.reviews.Count()
            }).ToPagedList(page, 10);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_movies", model));
            }
            return(View(model));
        }
        public object Get()
        {
            //   _movieDb = new MovieDb();
            var results =
                _movieDb.Query <Movie>().OrderByDescending(m => m.reviews.Count())
                .Select(m => new MovieViewModel
            {
                Id           = m.Id,
                MovieName    = m.MovieName,
                DirectorName = m.DirectorName,
                ReleaseYear  = m.ReleaseYear,
                NoOfReviews  = m.reviews.Count()
            });

            return(results);
        }