Exemplo n.º 1
0
        public ActionResult MovieInfo(int?id, string name, string type)
        {
            if (id == null || name == null || type == null)
            {
                Index(null, null, null);
                return(View("Index"));
            }
            else
            {
                List <TinyMovie> RecommendList = new List <TinyMovie>();
                //获取同类型的全部电影
                var recommend = from m in db.Movies
                                where m.type == type
                                select m;
                //去重复
                recommend = recommend.Where(x => x.name != name);
                //将当前电影信息加入List
                foreach (var r in recommend)
                {
                    TinyMovie tMovie = new TinyMovie(r.id, r.name, r.poster, r.type);
                    RecommendList.Add(tMovie);
                }
                ViewBag.Recommend = RecommendList;

                //获取与id相符的电影
                var movieByID = from m in db.Movies
                                where m.id == id
                                select m;

                //获取电影信息
                ViewBag.MovieInfo = HttpUtility.HtmlDecode(movieInfo.getMovieInfoByBaidu(name));

                return(View(movieByID));
            }
        }