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)); }
// // 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)); }
// // 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)); }