Ejemplo n.º 1
0
        public ActionResult CreateMovie(ManageMovieViewModel movie, System.Web.HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                return(View(movie));
            }
            if (file != null && file.ContentLength > 0)
            {
                var fileName = System.IO.Path.Combine(Request.MapPath("~/Content/Movie/"), System.IO.Path.GetFileName(file.FileName));
                file.SaveAs(fileName);
                movie.Avatar = System.IO.Path.GetFileName(file.FileName);
            }
            //MR_DataClassesDataContext _db = new MR_DataClassesDataContext();
            MRDataEntities _db = new MRDataEntities();

            if ((bool)_db.tbl_UserAccount.SingleOrDefault(u => u.user_Account == CookieHepler.GetCookie("user")).user_IsAdmin)
            {
                movie.Status = 2;
            }
            else
            {
                movie.Status = 0;
            }
            movie.Create = AccountManager.GetId(CookieHepler.GetCookie("user"));
            string newId = MovieManager.CreateMovie(movie);

            return(RedirectToAction("Index", new { id = newId }));
        }
Ejemplo n.º 2
0
        public ActionResult CreateCeleb(ManageCelebViewModel celeb, System.Web.HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                return(View(celeb));
            }
            if (file != null && file.ContentLength > 0)
            {
                var fileName = System.IO.Path.Combine(Request.MapPath("~/Content/Celeb/"), System.IO.Path.GetFileName(file.FileName));
                file.SaveAs(fileName);
                celeb.Avatar = System.IO.Path.GetFileName(file.FileName);
            }
            if ((bool)_db.tbl_UserAccount.SingleOrDefault(u => u.user_Account == CookieHepler.GetCookie("user")).user_IsAdmin)
            {
                celeb.Status = 2;
            }
            else
            {
                celeb.Status = 0;
            }
            celeb.Create = AccountManager.GetId(CookieHepler.GetCookie("user"));
            string newId = CelebManager.CreateCeleb(celeb);

            return(RedirectToAction("Edit", new { id = newId }));
        }
Ejemplo n.º 3
0
 public ActionResult Create(string content, string movie, string returnurl)
 {
     if (!string.IsNullOrEmpty(content) && MovieManager.Exist(movie) && User.Identity.IsAuthenticated)
     {
         CommentManager.Create(content, movie, AccountManager.GetId(CookieHepler.GetCookie("user")));
     }
     return(RedirectToLocal(returnurl));
 }
Ejemplo n.º 4
0
        public ActionResult ChangePassword()
        {
            ChangePasswordViewModel model = new ChangePasswordViewModel();

            //model.Account = CookieHepler.GetCookie("user");
            model.Account = CookieHepler.GetCookie("user");
            model.Avatar  = _db.tbl_UserAccount.Single(m => m.user_Account == model.Account).user_Avatar;
            return(View(model));
        }
Ejemplo n.º 5
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.º 6
0
        public ActionResult Over(string id, string returnUrl)
        {
            if (!AskManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            string user = AccountManager.GetId(CookieHepler.GetCookie("user"));

            if (_db.tbl_Mark.SingleOrDefault(w => w.mark_Target == id && w.mark_User == user && w.mark_Type == 6) == null)
            {
                AskManager.Over(id);
            }
            return(RedirectToLocal(returnUrl));
        }
Ejemplo n.º 7
0
 public ActionResult Cancel(string target, int type, string returnurl)
 {
     if (type <= 0 || type >= 7)
     {
         return(RedirectToAction("NotFound", "Error"));
     }
     else
     {
         if (type == 1 || type == 2 || type == 3)
         {
             if (!MovieManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
         else if (type == 4)
         {
             if (!CelebManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
         else if (type == 5)
         {
             if (!ResManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
         else if (type == 6)
         {
             if (!AskManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
         else
         {
             if (!AlbumManager.Exist(target))
             {
                 return(RedirectToAction("NotFound", "Error"));
             }
         }
     }
     if (CookieHepler.GetCookie("user") != null)
     {
         MarkManager.Cancel(target, AccountManager.GetId(CookieHepler.GetCookie("user")), type);
     }
     return(Redirect(returnurl));
 }
Ejemplo n.º 8
0
        public ActionResult Delete(string id, string returnurl)
        {
            if (!AskManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            var user  = _db.tbl_UserAccount.SingleOrDefault(m => m.user_Account == CookieHepler.GetCookie("user")).user_Id;
            var favor = _db.tbl_Ask.SingleOrDefault(m => m.ask_Id == id && m.ask_User == user);

            if (favor != null)
            {
                AskManager.Delete(id);
            }
            return(Redirect(returnurl));
        }
Ejemplo n.º 9
0
        public ActionResult ChangePassword(ChangePasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            //var result = AccountManager.ChangePassword(CookieHepler.GetCookie("user"), model.OldPassword, model.NewPassword);
            var result = AccountManager.ChangePassword(CookieHepler.GetCookie("user"), model.OldPassword, model.NewPassword);

            if (result.Succeeded)
            {
                //AccountManager.SignIn(CookieHepler.GetCookie("user"));
                AccountManager.SignInWithCookie();
            }
            ModelState.AddModelError("", result.Error);
            return(View(model));
        }
Ejemplo n.º 10
0
        public ActionResult Delete(string id, string returnurl)
        {
            if (!MovieManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            var user  = _db.tbl_UserAccount.SingleOrDefault(m => m.user_Account == CookieHepler.GetCookie("user")).user_Id;
            var favor = _db.tbl_Resource.SingleOrDefault(m => m.res_Id == id && m.res_User == user);

            if (favor != null)
            {
                string oldRes = _db.tbl_Resource.SingleOrDefault(m => m.res_Id == id).res_Content;
                ImageManager.Delete(Server.MapPath("~/Content/Torrent/" + oldRes));
                ResManager.Delete(id);
            }
            return(Redirect(returnurl));
        }
Ejemplo n.º 11
0
        public ActionResult CreateMovie(ManageMovieViewModel movie, System.Web.HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                return(View(movie));
            }
            if (file != null && file.ContentLength > 0)
            {
                var fileName = System.IO.Path.Combine(Request.MapPath("~/Content/Movie/"), System.IO.Path.GetFileName(file.FileName));
                file.SaveAs(fileName);
                movie.Avatar = System.IO.Path.GetFileName(file.FileName);
            }
            movie.Create = AccountManager.GetId(CookieHepler.GetCookie("user"));
            movie.Status = 2;
            string newId = MovieManager.CreateMovie(movie);

            return(RedirectToAction("Edit", new { id = newId }));
        }
Ejemplo n.º 12
0
        //
        // GET: /Album/Detail/
        public ActionResult Detail(string id, int page = 1)
        {
            if (!AlbumManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            tbl_Album      tblalbum = _db.tbl_Album.SingleOrDefault(s => s.album_Id == id);
            AlbumViewModel album    = new AlbumViewModel(tblalbum);

            if (tblalbum.album_User == AccountManager.GetId(CookieHepler.GetCookie("user")))
            {
                album.IsCreator = true;
            }
            if (User.Identity.IsAuthenticated)
            {
                if (_db.tbl_Mark.SingleOrDefault(f => f.mark_Target == id && f.mark_User == AccountManager.GetId(CookieHepler.GetCookie("user")) && f.mark_Type == 7) != null)
                {
                    album.HasFollow = true;
                }
            }

            List <AlbumItemViewModel> allItem = new List <AlbumItemViewModel>();

            //album.Items = new List<AlbumItemViewModel>();
            allItem     = Newtonsoft.Json.JsonConvert.DeserializeObject <List <AlbumItemViewModel> >(album.ItemJson);
            album.Count = allItem.Count;
            album.Items = allItem.Skip((page - 1) * album.ItemSize).Take(album.ItemSize).ToList();
            foreach (var item in album.Items)
            {
                item.MovieInfo = new MovieViewModel(_db.tbl_Movie.SingleOrDefault(m => m.movie_Id == item.Movie));
            }

            album.Page        = page;
            album.PagingCount = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(album.Count) / album.ItemSize));

            if (page > album.PagingCount && album.Items.Count > 0)
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            AlbumManager.Visit(id);
            return(View(album));
        }
Ejemplo n.º 13
0
        public ActionResult Favor(string id, string returnurl)
        {
            if (!MovieManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            var user  = _db.tbl_UserAccount.SingleOrDefault(m => m.user_Account == CookieHepler.GetCookie("user")).user_Id;
            var favor = _db.tbl_Mark.SingleOrDefault(m => m.mark_Target == id && m.mark_User == user);

            if (favor != null)
            {
                return(RedirectToAction("Create", "Mark", new { target = id, type = 5, returnurl = returnurl }));
            }
            else
            {
                return(RedirectToAction("Cancel", "Mark", new { target = id, type = 5, returnurl = returnurl }));
            }
        }
Ejemplo n.º 14
0
 public ActionResult Create(ManageAlbumViewModel model, System.Web.HttpPostedFileBase file)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     if (file != null && file.ContentLength > 0)
     {
         var fileName = System.IO.Path.Combine(Request.MapPath("~/Content/Album/"), System.IO.Path.GetFileName(file.FileName));
         file.SaveAs(fileName);
         model.Cover = System.IO.Path.GetFileName(file.FileName);
     }
     else
     {
         model.Cover = "Album_1.jpg";
     }
     model.UserId = AccountManager.GetId(CookieHepler.GetCookie("user"));
     model.Id     = AlbumManager.Create(model);
     return(RedirectToAction("Detail", new { id = model.Id }));
 }
Ejemplo n.º 15
0
        public ActionResult MineCeleb(int type)
        {
            if (type > 2 || type < 1)
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            ViewBag.CelebType = type;

            MineCelebViewModel mineceleb = new MineCelebViewModel();

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

            var collects = _db.tbl_Mark.Where(m => m.mark_User == mineceleb.Id && m.mark_Type == 4).OrderByDescending(m => m.mark_Time);

            mineceleb.CollectCount = collects.Count();
            var creates = _db.tbl_Celebrity.Where(c => c.celeb_Create == mineceleb.Id).OrderByDescending(c => c.celeb_Time);

            mineceleb.CreateCount = creates.Count();

            mineceleb.Celebs = new List <CelebViewModel>();
            if (type == 1)
            {
                foreach (var item in collects)
                {
                    CelebViewModel movie = new CelebViewModel(_db.tbl_Celebrity.Single(m => m.celeb_Id == item.mark_Target));
                    mineceleb.Celebs.Add(movie);
                }
            }
            else
            {
                foreach (var item in creates)
                {
                    CelebViewModel movie = new CelebViewModel(item);
                    mineceleb.Celebs.Add(movie);
                }
            }
            return(View(mineceleb));
        }
Ejemplo n.º 16
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(CookieHepler.GetCookie("user")), 4);

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

        //        if (tblCeleb.celeb_Create == AccountManager.GetId(CookieHepler.GetCookie("user")) || (bool)_db.tbl_UserAccount.SingleOrDefault(a => a.user_Account == CookieHepler.GetCookie("user")).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(CookieHepler.GetCookie("user")), 4);

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

                if (tblCeleb.celeb_Create == AccountManager.GetId(CookieHepler.GetCookie("user")) || (bool)_db.tbl_UserAccount.SingleOrDefault(a => a.user_Account == CookieHepler.GetCookie("user")).user_IsAdmin)
                {
                    celeb.IsCreate = true;
                }
            }
            return(View(celeb));
        }
Ejemplo n.º 17
0
        public ActionResult MineAlbum(int type)
        {
            if (type > 2 || type < 1)
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            MineAlbumViewModel minealbum = new MineAlbumViewModel();

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

            var albums = _db.tbl_Album.Where(a => a.album_User == minealbum.Id).OrderByDescending(m => m.album_Time);

            minealbum.AlbumCount = albums.Count();
            var follows = _db.tbl_Mark.Where(f => f.mark_User == minealbum.Id && f.mark_Type == 7).OrderByDescending(r => r.mark_Time);

            minealbum.FollowCount = follows.Count();

            minealbum.Albums = new List <AlbumViewModel>();
            if (type == 1)
            {
                foreach (var item in albums)
                {
                    minealbum.Albums.Add(new AlbumViewModel(item));
                }
            }
            else if (type == 2)
            {
                foreach (var item in follows)
                {
                    var album = _db.tbl_Album.SingleOrDefault(a => a.album_Id == item.mark_Target);
                    minealbum.Albums.Add(new AlbumViewModel(album));
                }
            }
            return(View(minealbum));
        }
Ejemplo n.º 18
0
        //
        // GET: /Ask/Index/
        public ActionResult Index()
        {
            IndexAskViewModel model = new IndexAskViewModel();

            var queryall = _db.tbl_Ask.OrderByDescending(a => a.ask_Time);

            foreach (var item in queryall)
            {
                AskViewModel ask = new AskViewModel(item);
                if (User.Identity.IsAuthenticated)
                {
                    string user = AccountManager.GetId(CookieHepler.GetCookie("user"));
                    if ((item.ask_User == user) || (_db.tbl_Mark.SingleOrDefault(w => w.mark_User == user && w.mark_Target == item.ask_Id && w.mark_Type == 6) != null))
                    {
                        ask.hadWith = true;
                    }
                }
                model.All.Add(ask);
            }

            var querymost = _db.tbl_Ask.OrderByDescending(a => a.ask_With).Take(20);

            foreach (var item in querymost)
            {
                AskViewModel ask = new AskViewModel(item);
                model.Most.Add(ask);
            }

            var queryover = _db.tbl_Ask.Where(a => a.ask_State == true).Take(20);

            foreach (var item in queryover)
            {
                AskViewModel ask = new AskViewModel(item);
                model.Over.Add(ask);
            }

            return(View(model));
        }
Ejemplo n.º 19
0
        public ActionResult MineRes()
        {
            MineResViewModel mineres = new MineResViewModel();

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

            var ress = _db.tbl_Resource.Where(r => r.res_User == mineres.Id).OrderByDescending(r => r.res_Time);

            mineres.ResCount = ress.Count();
            var asks = _db.tbl_Ask.Where(a => a.ask_User == mineres.Id).OrderByDescending(m => m.ask_Time);

            mineres.AskCount = asks.Count();

            mineres.Ress = new List <ResViewModel>();
            foreach (var item in ress)
            {
                mineres.Ress.Add(new ResViewModel(item));
            }
            return(View(mineres));
        }
Ejemplo n.º 20
0
        public ActionResult ChangeCover(ChangeCoverViewModel model, HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            //model.Id = _db.tbl_UserAccount.Single(m => m.user_Account == CookieHepler.GetCookie("user")).user_Id;
            model.Id = _db.tbl_UserAccount.Single(m => m.user_Account == CookieHepler.GetCookie("user")).user_Id;

            if (file != null && file.ContentLength > 0)
            {
                var fileName = System.IO.Path.Combine(Request.MapPath("~/Content/User/Cover/"), model.Id + System.IO.Path.GetFileName(file.FileName));
                file.SaveAs(fileName);
                model.Cover = model.Id + System.IO.Path.GetFileName(file.FileName);
                //string oldCover = _db.tbl_UserAccount.Single(m => m.user_Account == CookieHepler.GetCookie("user")).user_Cover;
                string oldCover = _db.tbl_UserAccount.Single(m => m.user_Account == CookieHepler.GetCookie("user")).user_Cover;
                if (model.Cover != oldCover && oldCover != "Cover_1.jpg" && oldCover != "Cover_2.jpg")
                {
                    ImageManager.Delete(Server.MapPath("~/Content/User/Cover/" + oldCover));
                }
            }
            else
            {
                ModelState.AddModelError("", "请选择一张图片");
                //model.Cover = _db.tbl_UserAccount.Single(m => m.user_Account == CookieHepler.GetCookie("user")).user_Avatar;
                model.Cover = _db.tbl_UserAccount.Single(m => m.user_Account == CookieHepler.GetCookie("user")).user_Avatar;
                return(View(model));
            }
            var result = AccountManager.ChangeCover(model);

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", result.Error);
            }
            return(View(model));
        }
Ejemplo n.º 21
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));
        }
Ejemplo n.º 22
0
 public ActionResult Create(CreateMovieViewModel movie)
 {
     if (!ModelState.IsValid)
     {
         return(View(movie));
     }
     foreach (var item in movie.DoubanID.Split('\n'))
     {
         if (item.Trim().Length == 0)
         {
             continue;
         }
         JObject json = HtmlDecoder.GetJson("https://api.douban.com/v2/movie/subject/" + item.Replace("https://movie.douban.com/subject/", "").Replace("/", ""));
         JToken  msg;
         if (json.TryGetValue("msg", out msg))
         {
             ModelState.AddModelError("", string.Format("{0} {1} {2}", "添加编号为", item, "的电影 失败"));
         }
         else
         {
             ModelState.AddModelError("", string.Format("{0} {1} {2}", "添加编号为", item, "的电影 成功"));
             MovieManager.CreateJson(json, Server.MapPath("~/Content/Movie/"), AccountManager.GetId(CookieHepler.GetCookie("user")));
         }
     }
     return(View());
 }
Ejemplo n.º 23
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.º 24
0
 public ActionResult Create(CreateCelebViewModel celeb)
 {
     if (!ModelState.IsValid)
     {
         return(View(celeb));
     }
     foreach (var item in celeb.DoubanID.Split('\n'))
     {
         if (item.Trim().Length == 0)
         {
             continue;
         }
         JObject json = HtmlDecoder.GetJson("https://api.douban.com/v2/movie/celebrity/" + item);
         JToken  msg;
         if (json.TryGetValue("msg", out msg))
         {
             ModelState.AddModelError("", string.Format("{0} {1} {2}", "添加编号为", item, "的影人 失败"));
         }
         else
         {
             ModelState.AddModelError("", string.Format("{0}{1}{2}", "添加编号为", item, "的影人 成功"));
             CelebManager.CreateJson(json, Server.MapPath("~/Content/Celeb/"), AccountManager.GetId(CookieHepler.GetCookie("user")));
         }
     }
     return(View());
 }
Ejemplo n.º 25
0
        public ActionResult CreateTorrent(ManageResViewModel model, System.Web.HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (file != null && file.ContentLength > 0)
            {
                if (System.IO.Path.GetExtension(file.FileName) == ".torrent")
                {
                    var fileName = System.IO.Path.Combine(Request.MapPath("~/Content/Torrent/"), model.Id + System.IO.Path.GetFileName(file.FileName));
                    file.SaveAs(fileName);
                    model.Content = System.IO.Path.GetFileName(file.FileName);
                    model.ResType = 2;

                    var user = _db.tbl_UserAccount.SingleOrDefault(u => u.user_Account == CookieHepler.GetCookie("user"));
                    if ((bool)user.user_IsAdmin)
                    {
                        model.Status = 2;
                    }
                    else
                    {
                        model.Status = 0;
                    }
                    model.User = user.user_Id;
                    ResManager.Create(model);
                    return(RedirectToAction("Index", "Movie", new { id = model.MovieId }));
                }
                else
                {
                    ModelState.AddModelError("", "请选择正确的torrent文件");
                    return(View(model));
                }
            }
            else
            {
                ModelState.AddModelError("", "请选择一个torrent文件");
                return(View(model));
            }
        }
Ejemplo n.º 26
0
        public ActionResult Create(ManageResViewModel model)
        {
            if (!string.IsNullOrEmpty(model.Content) && !string.IsNullOrWhiteSpace(model.Content))
            {
                model.Content = System.Web.HttpUtility.UrlDecode(model.Content);

                var user = _db.tbl_UserAccount.SingleOrDefault(u => u.user_Account == CookieHepler.GetCookie("user"));
                if ((bool)user.user_IsAdmin)
                {
                    model.Status = 2;
                }
                else
                {
                    model.Status = 0;
                    model.User   = user.user_Id;
                }
                if (model.Content.StartsWith("ed2k", true, null))
                {
                    model.ResType = 0;
                    ResManager.Create(model);
                    return(RedirectToAction("Index", "Movie", new { id = model.MovieId }));
                }
                else if (model.Content.StartsWith("magnet", true, null))
                {
                    model.ResType = 1;
                    ResManager.Create(model);
                    return(RedirectToAction("Index", "Movie", new { id = model.MovieId }));
                }
                else
                {
                    ModelState.AddModelError("", "URL不合法,请重新输入。");
                    return(View(model));
                }
            }
            else
            {
                ModelState.AddModelError("", "URL不能为空,请重新输入URL。");
                return(View(model));
            }
        }
Ejemplo n.º 27
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.º 28
0
        //
        // GET: /People/Index/
        public ActionResult Index(string id, string returnurl)
        {
            if (!AccountManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            //MR_DataClassesDataContext _db = new MR_DataClassesDataContext();
            MRDataEntities  _db   = new MRDataEntities();
            PeopleViewModel model = new PeopleViewModel();

            model.Id      = id;
            model.Avatar  = _db.tbl_UserAccount.Single(m => m.user_Id == model.Id).user_Avatar;
            model.Cover   = _db.tbl_UserAccount.Single(m => m.user_Id == model.Id).user_Cover;
            model.Account = _db.tbl_UserAccount.Single(m => m.user_Id == model.Id).user_Account;

            if ((bool)_db.tbl_UserAccount.Single(m => m.user_Id == model.Id).user_IsAdmin)
            {
                return(Redirect(returnurl));
            }

            if (User.Identity.IsAuthenticated)
            {
                string userid = AccountManager.GetId(CookieHepler.GetCookie("user"));
                if (userid == id)
                {
                    return(RedirectToAction("Index", "Mine"));
                }
                model.MovieCommons = new List <MarkItem>();
                var peoplefavors = _db.tbl_Mark.Where(m => m.mark_User == model.Id && m.mark_Type == 3);
                foreach (var item in peoplefavors)
                {
                    if (_db.tbl_Mark.SingleOrDefault(m => m.mark_Target == item.mark_Target && m.mark_User == userid && m.mark_Type == 3) != null)
                    {
                        MarkItem mitem = new MarkItem();
                        mitem.Id     = item.mark_Target;
                        mitem.Avatar = _db.tbl_Movie.Single(m => m.movie_Id == item.mark_Target).movie_Avatar;
                        mitem.Title  = _db.tbl_Movie.Single(m => m.movie_Id == item.mark_Target).movie_Title;
                        model.MovieCommons.Add(mitem);
                    }
                }
                model.CommonCount  = model.MovieCommons.Count;
                model.MovieCommons = model.MovieCommons.Take(10).ToList();
            }
            else
            {
                model.MovieCommons = new List <MarkItem>();
                model.CommonCount  = 0;
            }

            var plans = _db.tbl_Mark.Where(m => m.mark_User == model.Id && m.mark_Type == 1).OrderByDescending(m => m.mark_Time).Take(10);

            model.PlanCount  = _db.tbl_Mark.Where(m => m.mark_User == model.Id && m.mark_Type == 1).OrderByDescending(m => m.mark_Time).Count();
            model.MoviePlans = new List <MarkItem>();
            if (model.PlanCount != 0)
            {
                foreach (var item in plans)
                {
                    MarkItem mitem = new MarkItem();
                    mitem.Id     = item.mark_Target;
                    mitem.Avatar = _db.tbl_Movie.Single(m => m.movie_Id == item.mark_Target).movie_Avatar;
                    mitem.Title  = _db.tbl_Movie.Single(m => m.movie_Id == item.mark_Target).movie_Title;
                    model.MoviePlans.Add(mitem);
                }
            }

            var finishs = _db.tbl_Mark.Where(m => m.mark_User == model.Id && m.mark_Type == 2).OrderByDescending(m => m.mark_Time).Take(10);

            model.FinishCount  = _db.tbl_Mark.Where(m => m.mark_User == model.Id && m.mark_Type == 2).OrderByDescending(m => m.mark_Time).Count();
            model.MovieFinishs = new List <MarkItem>();
            if (model.FinishCount != 0)
            {
                foreach (var item in finishs)
                {
                    MarkItem mitem = new MarkItem();
                    mitem.Id     = item.mark_Target;
                    mitem.Avatar = _db.tbl_Movie.Single(m => m.movie_Id == item.mark_Target).movie_Avatar;
                    mitem.Title  = _db.tbl_Movie.Single(m => m.movie_Id == item.mark_Target).movie_Title;
                    model.MovieFinishs.Add(mitem);
                }
            }

            var favors = _db.tbl_Mark.Where(m => m.mark_User == model.Id && m.mark_Type == 3).OrderByDescending(m => m.mark_Time);

            model.FavorCount  = favors.Count();
            model.MovieFavors = new List <MarkItem>();
            if (model.FavorCount != 0)
            {
                foreach (var item in favors.Take(10))
                {
                    MarkItem mitem = new MarkItem();
                    mitem.Id     = item.mark_Target;
                    mitem.Avatar = _db.tbl_Movie.Single(m => m.movie_Id == item.mark_Target).movie_Avatar;
                    mitem.Title  = _db.tbl_Movie.Single(m => m.movie_Id == item.mark_Target).movie_Title;
                    model.MovieFavors.Add(mitem);
                }
            }

            var collects = _db.tbl_Mark.Where(m => m.mark_User == model.Id && m.mark_Type == 4).OrderByDescending(m => m.mark_Time);

            model.CollectCount  = collects.Count();
            model.CelebCollects = new List <MarkItem>();
            if (model.CollectCount != 0)
            {
                foreach (var item in collects.Take(10))
                {
                    MarkItem mitem = new MarkItem();
                    mitem.Id     = item.mark_Target;
                    mitem.Avatar = _db.tbl_Celebrity.Single(m => m.celeb_Id == item.mark_Target).celeb_Avatar;
                    mitem.Title  = _db.tbl_Celebrity.Single(m => m.celeb_Id == item.mark_Target).celeb_Name;
                    model.CelebCollects.Add(mitem);
                }
            }

            var albums = _db.tbl_Album.Where(a => a.album_User == model.Id).OrderByDescending(a => a.album_AlterTime);

            model.AlbumCount = albums.Count();
            model.Albums     = new List <AlbumListItem>();
            if (model.AlbumCount != 0)
            {
                foreach (var item in albums)
                {
                    model.Albums.Add(new AlbumListItem(item));
                }
            }

            var comments = _db.tbl_Comment.Where(c => c.cmt_User == model.Id).OrderByDescending(c => c.cmt_Time);

            model.CommentCount = comments.Count();
            model.Comments     = new List <CommentItem>();
            if (model.AlbumCount != 0)
            {
                foreach (var item in comments)
                {
                    CommentItem citem = new CommentItem();
                    citem.MovieID    = item.cmt_Movie;
                    citem.MovieTitle = MovieManager.GetTitle(item.cmt_Movie);
                    citem.Comment    = item.cmt_Content;
                    citem.Time       = ((System.DateTime)item.cmt_Time).ToString("yyyy-MM-dd hh:mm:ss");
                    model.Comments.Add(citem);
                }
            }

            return(View(model));
        }
Ejemplo n.º 29
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(CookieHepler.GetCookie("user")), 1);
                    celeb.Works[i].Work.IsFinish = MarkManager.Validate(celeb.Works[i].Work.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 2);
                    celeb.Works[i].Work.IsFavor  = MarkManager.Validate(celeb.Works[i].Work.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 3);
                }
            }
            return(View(celeb));
        }
Ejemplo n.º 30
0
 public ActionResult Create(ManageAskViewModel model)
 {
     if (!string.IsNullOrEmpty(model.Note) && !string.IsNullOrWhiteSpace(model.Note))
     {
         var user = _db.tbl_UserAccount.SingleOrDefault(u => u.user_Account == CookieHepler.GetCookie("user"));
         model.User = user.user_Id;
         AskManager.Create(model);
         return(RedirectToAction("Index", "Movie", new { id = model.MovieId }));
     }
     else
     {
         ModelState.AddModelError("", "备注 不能为空,请重新输入 备注。");
         return(View(model));
     }
 }