Ejemplo n.º 1
0
        //
        // GET: /Home/Index/
        public ActionResult Index(int offset = 0)
        {
            HomeViewModel model = new HomeViewModel();
            //MR_DataClassesDataContext _db = new MR_DataClassesDataContext();
            MRDataEntities _db = new MRDataEntities();

            var dis = _db.tbl_Discovery.OrderByDescending(d => d.disc_Flag).ToList();

            if (offset >= dis.Count || offset < 0)
            {
                return(Redirect("/Home/Index?offset=0"));
            }
            model.Discovery        = new HomeDiscViewModel(dis[offset]);
            model.Discovery.Offset = offset;
            model.Discovery.Post   = offset - 1;
            model.Discovery.Pre    = offset + 1;
            if (User.Identity.IsAuthenticated)
            {
                model.Discovery.Movie.IsPlan   = MarkManager.Validate(model.Discovery.Movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 1);
                model.Discovery.Movie.IsFinish = MarkManager.Validate(model.Discovery.Movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 2);
                model.Discovery.Movie.IsFavor  = MarkManager.Validate(model.Discovery.Movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 3);
            }

            var newmovie = _db.tbl_Movie.Where(m => m.movie_Status == 2).OrderByDescending(m => m.movie_Time).ToList().Take(20);

            model.News = new List <MovieListViewModel>();
            foreach (var item in newmovie)
            {
                MovieListViewModel movie = new MovieListViewModel();
                movie.Title = item.movie_Title;
                if (!string.IsNullOrEmpty(item.movie_TitleEn) && !string.IsNullOrWhiteSpace(item.movie_TitleEn))
                {
                    movie.Title += "\t" + item.movie_TitleEn;
                }
                movie.Year = item.movie_Year;
                movie.Id   = item.movie_Id;
                model.News.Add(movie);
            }

            var mostmovie = _db.tbl_Movie.Where(m => m.movie_Status == 2).OrderByDescending(m => m.movie_VisitCount).ToList().Take(20);

            model.Mosts = new List <MovieListViewModel>();
            foreach (var item in mostmovie)
            {
                MovieListViewModel movie = new MovieListViewModel();
                movie.Title = item.movie_Title;
                if (!string.IsNullOrEmpty(item.movie_TitleEn) && !string.IsNullOrWhiteSpace(item.movie_TitleEn))
                {
                    movie.Title += "\t" + item.movie_TitleEn;
                }
                movie.Year = item.movie_Year;
                movie.Id   = item.movie_Id;
                model.Mosts.Add(movie);
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        //
        // GET: /Search/
        public ActionResult Index(string search, string genre = "0", string country = "0", string year = "0", int page = 1)
        {
            //MR_DataClassesDataContext _db = new MR_DataClassesDataContext();
            MRDataEntities    _db        = new MRDataEntities();
            ClassifyViewModel movieGroup = new ClassifyViewModel();
            var filterMovie = from m in _db.tbl_Movie
                              where m.movie_Status == 2
                              select m;

            if (!string.IsNullOrEmpty(search) && !string.IsNullOrWhiteSpace(search))
            {
                filterMovie = filterMovie.Where(m => m.movie_Title.Contains(search) || m.movie_TitleEn.Contains(search) || m.movie_Aka.Contains(search));
            }
            if (genre != "0")
            {
                filterMovie = filterMovie.Where(m => m.movie_Genres.IndexOf(genre) > -1);
            }
            if (country != "0")
            {
                filterMovie = filterMovie.Where(m => m.movie_Countries.IndexOf(country) > -1);
            }
            if (year != "0")
            {
                filterMovie = filterMovie.Where(m => m.movie_Year == year);
            }
            filterMovie.OrderByDescending(m => m.movie_Time);
            movieGroup.listMovies.Clear();
            foreach (var item in filterMovie)
            {
                MovieViewModel movie = new MovieViewModel(item);
                movie.IsPlan   = MarkManager.Validate(item.movie_Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 1);
                movie.IsFinish = MarkManager.Validate(item.movie_Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 2);
                movie.IsFavor  = MarkManager.Validate(item.movie_Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 3);
                movieGroup.listMovies.Add(movie);
            }
            movieGroup.Count   = movieGroup.listMovies.Count();
            movieGroup.Search  = search;
            movieGroup.Genre   = genre;
            movieGroup.Country = country;
            movieGroup.Year    = year;

            movieGroup.Page        = page;
            movieGroup.PagingCount = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(movieGroup.Count) / movieGroup.MovieSize));

            movieGroup.listMovies = movieGroup.listMovies.Skip((page - 1) * movieGroup.MovieSize).Take(movieGroup.MovieSize).ToList();
            if (page > movieGroup.PagingCount && movieGroup.listMovies.Count > 0)
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            string url = Translator.BuildUrl(Request.Url.ToString(), "search", search);

            url = Translator.BuildUrl(url, "genre", genre);
            url = Translator.BuildUrl(url, "country", country);
            url = Translator.BuildUrl(url, "year", year);
            ViewBag.CurrentUrl = url;
            return(View(movieGroup));
        }
Ejemplo n.º 3
0
        public ActionResult MineMovie(int type)
        {
            if (type > 4 || type < 1)
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            ViewBag.MovieType = type;

            MineMovieViewModel minemovie = new MineMovieViewModel();

            //minemovie.Account = CookieHepler.GetCookie("user");
            minemovie.Account = CookieHepler.GetCookie("user");
            minemovie.Id      = AccountManager.GetId(minemovie.Account);
            minemovie.Avatar  = _db.tbl_UserAccount.SingleOrDefault(a => a.user_Id == minemovie.Id).user_Avatar;

            minemovie.PlanCount   = _db.tbl_Mark.Where(m => m.mark_User == minemovie.Id && m.mark_Type == 1).Count();
            minemovie.FinishCount = _db.tbl_Mark.Where(m => m.mark_User == minemovie.Id && m.mark_Type == 2).Count();
            minemovie.FavorCount  = _db.tbl_Mark.Where(m => m.mark_User == minemovie.Id && m.mark_Type == 3).Count();
            minemovie.CreateCount = _db.tbl_Movie.Where(m => m.movie_Create == minemovie.Id).Count();

            minemovie.Moives = new List <MovieViewModel>();
            if (type == 1 || type == 2 || type == 3)
            {
                var movies = _db.tbl_Mark.Where(m => m.mark_User == minemovie.Id && m.mark_Type == type).OrderByDescending(m => m.mark_Time);
                foreach (var item in movies)
                {
                    MovieViewModel movie = new MovieViewModel(_db.tbl_Movie.Single(m => m.movie_Id == item.mark_Target));
                    //movie.IsPlan = MarkManager.Validate(movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 1);
                    //movie.IsFinish = MarkManager.Validate(movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 2);
                    //movie.IsFavor = MarkManager.Validate(movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 3);
                    movie.IsPlan   = MarkManager.Validate(movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 1);
                    movie.IsFinish = MarkManager.Validate(movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 2);
                    movie.IsFavor  = MarkManager.Validate(movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 3);
                    minemovie.Moives.Add(movie);
                }
            }
            else
            {
                var movies = _db.tbl_Movie.Where(m => m.movie_Create == minemovie.Id).OrderByDescending(m => m.movie_Time);
                foreach (var item in movies)
                {
                    MovieViewModel movie = new MovieViewModel(item);
                    //movie.IsPlan = MarkManager.Validate(movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 1);
                    //movie.IsFinish = MarkManager.Validate(movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 2);
                    //movie.IsFavor = MarkManager.Validate(movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 3);
                    movie.IsPlan   = MarkManager.Validate(movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 1);
                    movie.IsFinish = MarkManager.Validate(movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 2);
                    movie.IsFavor  = MarkManager.Validate(movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 3);
                    minemovie.Moives.Add(movie);
                }
            }
            return(View(minemovie));
        }
Ejemplo n.º 4
0
        //
        // GET: /Celeb/Work/
        public ActionResult Work(string id)
        {
            if (!CelebManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            tbl_Celebrity  tblCeleb = _db.tbl_Celebrity.SingleOrDefault(s => s.celeb_Id == id);
            CelebViewModel celeb    = new CelebViewModel(tblCeleb);

            if (User.Identity.IsAuthenticated)
            {
                for (int i = 0; i < celeb.Works.Count(); i++)
                {
                    MovieViewModel movie = celeb.Works[i].Work;
                    celeb.Works[i].Work.IsPlan   = MarkManager.Validate(celeb.Works[i].Work.Id, AccountManager.GetId(User.Identity.Name), 1);
                    celeb.Works[i].Work.IsFinish = MarkManager.Validate(celeb.Works[i].Work.Id, AccountManager.GetId(User.Identity.Name), 2);
                    celeb.Works[i].Work.IsFavor  = MarkManager.Validate(celeb.Works[i].Work.Id, AccountManager.GetId(User.Identity.Name), 3);
                }
            }
            return(View(celeb));
        }
Ejemplo n.º 5
0
        //
        // GET: /Celeb/Index/
        //public ActionResult Index(string id)
        //{
        //    if (!CelebManager.Exist(id))
        //    {
        //        return RedirectToAction("NotFound", "Error");
        //    }
        //    tbl_Celebrity tblCeleb = _db.tbl_Celebrity.SingleOrDefault(s => s.celeb_Id == id);
        //    CelebViewModel celeb = new CelebViewModel(tblCeleb);

        //    if (User.Identity.IsAuthenticated)
        //    {
        //        celeb.IsCollect = MarkManager.Validate(tblCeleb.celeb_Id, AccountManager.GetId(User.Identity.Name), 4);

        //        celeb.CollectCount = _db.tbl_Mark.Where(m => m.mark_Target == id && m.mark_Type == 4).Count();

        //        if (tblCeleb.celeb_Create == AccountManager.GetId(User.Identity.Name) || (bool)_db.tbl_UserAccount.SingleOrDefault(a => a.user_Account == User.Identity.Name).user_IsAdmin)
        //        {
        //            celeb.IsCreate = true;
        //        }
        //    }
        //    return View(celeb);
        //}
        public ActionResult Index(string id)
        {
            if (!CelebManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            tbl_Celebrity  tblCeleb = _db.tbl_Celebrity.SingleOrDefault(s => s.celeb_Id == id);
            CelebViewModel celeb    = new CelebViewModel(tblCeleb);

            if (User.Identity.IsAuthenticated)
            {
                celeb.IsCollect = MarkManager.Validate(tblCeleb.celeb_Id, AccountManager.GetId(User.Identity.Name), 4);

                celeb.CollectCount = _db.tbl_Mark.Where(m => m.mark_Target == id && m.mark_Type == 4).Count();

                if (tblCeleb.celeb_Create == AccountManager.GetId(User.Identity.Name) || (bool)_db.tbl_UserAccount.SingleOrDefault(a => a.user_Account == User.Identity.Name).user_IsAdmin)
                {
                    celeb.IsCreate = true;
                }
            }
            return(View(celeb));
        }
Ejemplo n.º 6
0
        ////
        //// GET: /Movie/IndexNew/
        public ActionResult Index(string id)
        {
            if (!MovieManager.Exist(id))
            {
                //return HttpNotFound();
                return(RedirectToAction("NotFound", "Error"));
            }
            tbl_Movie tblmovie = _db.tbl_Movie.SingleOrDefault(s => s.movie_Id == id);

            if (tblmovie == null)
            {
                //return HttpNotFound();
                return(RedirectToAction("NotFound", "Error"));
            }
            MovieViewModel movie = new MovieViewModel(tblmovie);

            if (User.Identity.IsAuthenticated)
            {
                movie.IsPlan   = MarkManager.Validate(tblmovie.movie_Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 1);
                movie.IsFinish = MarkManager.Validate(tblmovie.movie_Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 2);
                movie.IsFavor  = MarkManager.Validate(tblmovie.movie_Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 3);

                movie.PlanCount   = _db.tbl_Mark.Where(m => m.mark_Target == id && m.mark_Type == 1).Count();
                movie.FinishCount = _db.tbl_Mark.Where(m => m.mark_Target == id && m.mark_Type == 2).Count();
                movie.FavorCount  = _db.tbl_Mark.Where(m => m.mark_Target == id && m.mark_Type == 3).Count();

                if (tblmovie.movie_Create == AccountManager.GetId(CookieHepler.GetCookie("user")) || (bool)_db.tbl_UserAccount.SingleOrDefault(a => a.user_Account == CookieHepler.GetCookie("user")).user_IsAdmin)
                {
                    movie.IsCreate = true;
                }
                var cmt = _db.tbl_Comment.SingleOrDefault(c => c.cmt_Movie == id && c.cmt_User == AccountManager.GetId(CookieHepler.GetCookie("user")));
                if (cmt != null)
                {
                    movie.MyComment = new CommentViewModel(cmt);
                }
            }

            var ress = _db.tbl_Resource.Where(m => m.res_Movie == movie.Id && m.res_Status == 2);

            movie.Resources = new List <ResViewModel>();
            foreach (var item in ress)
            {
                movie.Resources.Add(new ResViewModel(item));
            }

            var allcmt = _db.tbl_Comment.Where(c => c.cmt_Movie == id).OrderByDescending(c => c.cmt_Time).Take(10);

            movie.Comments = new List <CommentViewModel>();
            foreach (var item in allcmt)
            {
                movie.Comments.Add(new CommentViewModel(item));
            }
            movie.CommentCount = _db.tbl_Comment.Where(c => c.cmt_Movie == id).Count();

            var albums = _db.tbl_Album.Where(a => a.album_Item.Contains(movie.Id)).OrderByDescending(a => a.album_Time).Take(15);

            movie.Albums = new List <LinkItem>();
            foreach (var item in albums)
            {
                movie.Albums.Add(new LinkItem()
                {
                    Id = item.album_Id, Title = item.album_Title
                });
            }

            MovieManager.Visit(id);
            return(View(movie));
        }