Ejemplo n.º 1
0
        public ActionResult ListLastYearJson(JqGridRequest request)
        {
            var        movieList = MovieListBL.GetLastYearForListing( ).AsQueryable( );
            JqGridData result    = GetGridData(request, movieList);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult GetSuperSearchForWriter(JqGridRequest request)
        {
            string     keyword   = GetSearchKeyword( );
            var        movieList = MovieListBL.SearchSuperblyForWriters(keyword).AsQueryable( );
            JqGridData result    = GetGridData(request, movieList);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public List <MovieDO> DoFilter(List <MovieDO> movieList, int userID)
        {
            //filter names
            if (string.IsNullOrEmpty(Name.FilterValue) == false)
            {
                var tempList = MovieListBL.SearchSuperblyForNames(Name.FilterValue).Select(q => q.ID);
                movieList = movieList.Where(q => tempList.Contains(q.ID)).ToList();
            }

            //filter year
            if (string.IsNullOrEmpty(Year.FilterValue) == false)
            {
                int year = ParseHelper.ToInt32(Year.FilterValue);
                if (year > 0)
                {
                    if (Year.FilterType == FilterTypes.Equals)
                    {
                        movieList = movieList.Where(q => q.Year.HasValue && q.Year.Value == year).ToList();
                    }
                    if (Year.FilterType == FilterTypes.GreaterThanOrEqual)
                    {
                        movieList = movieList.Where(q => q.Year.HasValue && q.Year.Value >= year).ToList();
                    }
                    if (Year.FilterType == FilterTypes.LessThanOrEqual)
                    {
                        movieList = movieList.Where(q => q.Year.HasValue && q.Year.Value <= year).ToList();
                    }
                }
            }

            //filter imdb rating
            if (string.IsNullOrEmpty(ImdbRating.FilterValue) == false)
            {
                double imdbRating = ParseHelper.ToDouble(ImdbRating.FilterValue);
                if (imdbRating > 0)
                {
                    if (ImdbRating.FilterType == FilterTypes.Equals)
                    {
                        movieList = movieList.Where(q => q.ImdbRating.HasValue && q.ImdbRating.Value == imdbRating).ToList();
                    }
                    if (ImdbRating.FilterType == FilterTypes.GreaterThanOrEqual)
                    {
                        movieList = movieList.Where(q => q.ImdbRating.HasValue && q.ImdbRating.Value >= imdbRating).ToList();
                    }
                    if (ImdbRating.FilterType == FilterTypes.LessThanOrEqual)
                    {
                        movieList = movieList.Where(q => q.ImdbRating.HasValue && q.ImdbRating.Value <= imdbRating).ToList();
                    }
                }
            }

            //filter i have watched
            if (string.IsNullOrEmpty(IHaveWatched.FilterValue) == false)
            {
                string watchedStatus = IHaveWatched.FilterValue;

                if (watchedStatus != "All")
                {
                    List <MovieUserRatingDO> usersRatings = MovieUserRatingBL.GetAllDOByUserID(userID);
                    List <int> movieIds = usersRatings.Where(q => q.Watched == true).Select(q => q.MovieID).ToList();
                    if (watchedStatus == "No")
                    {
                        movieList.RemoveAll(q => movieIds.Contains(q.ID));
                    }
                    else if (watchedStatus == "Yes")
                    {
                        movieList = movieList.Where(q => movieIds.Contains(q.ID)).ToList();
                    }
                }
            }

            //filter my rating
            if (string.IsNullOrEmpty(MyRating.FilterValue) == false)
            {
                double myRating = ParseHelper.ToDouble(MyRating.FilterValue);
                if (myRating > 0)
                {
                    List <int> movieIdsForUsersRatings = new List <int>();
                    if (MyRating.FilterType == FilterTypes.Equals)
                    {
                        movieIdsForUsersRatings = MovieUserRatingBL.GetAllDOByUserID(userID).Where(q => q.Rating == myRating).Select(q => q.MovieID).ToList();
                    }
                    if (MyRating.FilterType == FilterTypes.GreaterThanOrEqual)
                    {
                        movieIdsForUsersRatings = MovieUserRatingBL.GetAllDOByUserID(userID).Where(q => q.Rating >= myRating).Select(q => q.MovieID).ToList();
                    }
                    if (MyRating.FilterType == FilterTypes.LessThanOrEqual)
                    {
                        movieIdsForUsersRatings = MovieUserRatingBL.GetAllDOByUserID(userID).Where(q => q.Rating <= myRating).Select(q => q.MovieID).ToList();
                    }

                    movieList = movieList.Where(q => movieIdsForUsersRatings.Contains(q.ID)).ToList();
                }
            }

            //filter movie types
            if (MovieType.Length > 0)
            {
                List <int> typeIds = new List <int>();
                foreach (var item in MovieType)
                {
                    typeIds.Add(ParseHelper.ToInt32(item));
                }

                var allMoviesAndTypes = MovieTypeBL.GetAllDO().Where(q => typeIds.Contains(q.TypeID));
                movieList = movieList.Join(allMoviesAndTypes, mList => mList.ID, allMovs => allMovs.MovieID, (mList, allMovs) => mList).ToList();
            }

            return(movieList);
        }