Ejemplo n.º 1
0
        public ActionResult SearchAuto(MovyEntity movie)
        {
            List <SelectListItem> genreList = GenreBL.ViewAllGenreBL().Select(n => new SelectListItem {
                Value = n.GenreId.ToString(), Text = n.GenreName
            }).ToList();;

            var genreTip = new SelectListItem()
            {
                Value = null,
                Text  = "-- genre --"
            };

            genreList.Insert(0, genreTip);
            ViewBag.generList = new SelectList(genreList, "Value", "Text");

            List <SelectListItem> languageList = LanguageBL.ViewAllLanguageBL().Select(n => new SelectListItem {
                Value = n.LanguageId.ToString(), Text = n.LanguageName
            }).ToList();;

            var languageTip = new SelectListItem()
            {
                Value = null,
                Text  = "--  Language --"
            };

            languageList.Insert(0, languageTip);
            ViewBag.langList = new SelectList(languageList, "Value", "Text");
            ////Note : you can bind same list from database
            List <MovyEntityNew> ObjList = new List <MovyEntityNew>();

            ObjList = MovieBL.GetAllMoviesBL();
            ////Searching records from list using LINQ query
            //var movieList = (from N in ObjList
            //                where N.MovieName.StartsWith(Prefix) || N.MovieName.StartsWith(Prefix.ElementAt(0).ToString().ToUpper())
            //                 select new { N.MovieName });
            //return Json(movieList, JsonRequestBehavior.AllowGet);
            var movieList = (from N in ObjList
                             where N.MovieName.ToLower().Equals(movie.MovieName.ToLower())
                             select N);
            MovyEntityNew movieResult = movieList.FirstOrDefault();

            if (movieResult != null)
            {
                string url = string.Format("/Movies/MovieDetails/" + movieResult.MovieId);
                return(Redirect(url));
            }
            else
            {
                string url = string.Format("/Movies/ListAllMovies");
                return(Redirect(url));
            }
        }
Ejemplo n.º 2
0
        // GET: Movies

        public ActionResult ListAllMovies(MovyEntityNew movie, MovyEntity movieFilter)
        {
            List <SelectListItem> genreList = GenreBL.ViewAllGenreBL().Select(n => new SelectListItem {
                Value = n.GenreId.ToString(), Text = n.GenreName
            }).ToList();;

            var genreTip = new SelectListItem()
            {
                Value = null,
                Text  = "-- genre --"
            };

            genreList.Insert(0, genreTip);
            ViewBag.generList = new SelectList(genreList, "Value", "Text");

            List <SelectListItem> languageList = LanguageBL.ViewAllLanguageBL().Select(n => new SelectListItem {
                Value = n.LanguageId.ToString(), Text = n.LanguageName
            }).ToList();;

            var languageTip = new SelectListItem()
            {
                Value = null,
                Text  = "--  Language --"
            };

            languageList.Insert(0, languageTip);
            ViewBag.langList = new SelectList(languageList, "Value", "Text");
            string username     = Request.QueryString["username"];
            string genrename    = GenreBL.SearchGenreBL(movieFilter.GenreId).GenreName;
            string languagename = LanguageBL.SearchLanguageBL(movieFilter.LanguageId).LanguageName;


            List <MovyEntityNew> listMovies = MovieBL.GetAllMoviesBL();
            var query = from item in listMovies
                        where item.Genre.Equals(genrename) || movieFilter.GenreId == 0
                        where item.Language.Equals(languagename) || movieFilter.LanguageId == 0
                        select item;

            if (Session["Username"] != null && Session["ViewerId"] != null)
            {
                ViewBag.ViewerId = Session["ViewerId"];
                return(View(query));
            }
            else
            {
                string url = string.Format("/Users/LogIn");
                return(Redirect(url));
            }
        }
Ejemplo n.º 3
0
        public List <MovyEntityNew> GetAllMoviesDAL()
        {
            List <MovyEntityNew> result = new List <MovyEntityNew>();

            CinestarEntitiesDAL ObjContext = new CinestarEntitiesDAL();

            var ObjMovieList = from Movie in ObjContext.Movies
                               join Genre in ObjContext.Genres
                               on Movie.GenreId equals Genre.GenreId
                               join Language in ObjContext.Languages
                               on Movie.LanguageId equals Language.LanguageId
                               select new MovyEntityNew {
                Genre            = Genre.GenreName,
                Language         = Language.LanguageName,
                MovieDescription = Movie.MovieDescription,
                MovieId          = Movie.MovieId,
                MovieName        = Movie.MovieName,
                MovieUrl         = Movie.MovieUrl,
                ReleaseDate      = Movie.ReleaseDate
            };


            foreach (var item in ObjMovieList)
            {
                MovyEntityNew entity = new MovyEntityNew();
                entity.Genre            = item.Genre;
                entity.Language         = item.Language;
                entity.MovieDescription = item.MovieDescription;
                entity.MovieId          = item.MovieId;
                entity.MovieName        = item.MovieName;
                entity.MovieUrl         = item.MovieUrl;
                entity.ReleaseDate      = item.ReleaseDate;
                result.Add(entity);
            }



            return(result);
        }