示例#1
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(User.Identity.Name));
         }
     }
     return(View());
 }
示例#2
0
        public ActionResult Refresh(string id)
        {
            if (!CelebManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            RefreshCelebViewModel refresh = new RefreshCelebViewModel();

            tbl_Celebrity tblceleb = _db.tbl_Celebrity.SingleOrDefault(s => s.celeb_Id == id);

            refresh.Old = new ManageCelebViewModel(tblceleb);

            JObject json = HtmlDecoder.GetJson("https://api.douban.com/v2/movie/celebrity/" + tblceleb.celeb_DoubanID);
            JToken  msg;

            if (json.TryGetValue("msg", out msg))
            {
                refresh.New    = new ManageCelebViewModel();
                refresh.New.Id = refresh.Old.Id;
            }
            else
            {
                tblceleb       = CelebManager.JsonToCeleb(json, Server.MapPath("~/Content/Celeb/"));
                refresh.New    = new ManageCelebViewModel(tblceleb);
                refresh.New.Id = refresh.Old.Id;
            }
            TempData["NewCeleb"] = refresh.New;

            return(View(refresh));
        }
示例#3
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 == User.Identity.Name).user_IsAdmin)
            {
                celeb.Status = 2;
            }
            else
            {
                celeb.Status = 0;
            }
            celeb.Create = AccountManager.GetId(User.Identity.Name);
            string newId = CelebManager.CreateCeleb(celeb);

            return(RedirectToAction("Edit", new { id = newId }));
        }
示例#4
0
 public ActionResult Audit(string id, string returnurl)
 {
     if (!MovieManager.Exist(id))
     {
         return(RedirectToAction("NotFound", "Error"));
     }
     CelebManager.Audit(id);
     return(RedirectToLocal(returnurl));
 }
示例#5
0
        public ActionResult Delete(string id)
        {
            if (!CelebManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            tbl_Celebrity        tblceleb = _db.tbl_Celebrity.SingleOrDefault(s => s.celeb_Id == id);
            ManageCelebViewModel celeb    = new ManageCelebViewModel(tblceleb);

            return(View(celeb));
        }
示例#6
0
        public ActionResult Reject(string id, string returnurl)
        {
            if (!CelebManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            RejectViewModel model = new RejectViewModel();

            model.Id          = id;
            ViewBag.ReturnUrl = returnurl;
            return(View(model));
        }
示例#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 (User.Identity.Name != null)
     {
         MarkManager.Cancel(target, AccountManager.GetId(User.Identity.Name), type);
     }
     return(Redirect(returnurl));
 }
 public ActionResult Create(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.Create(target, AccountManager.GetId(CookieHepler.GetCookie("user")), type);
     }
     return(Redirect(returnurl));
 }
示例#9
0
        public ActionResult RefreshConfirm(string id)
        {
            if (!CelebManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            ManageCelebViewModel newceleb = TempData["NewCeleb"] as ManageCelebViewModel;

            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Edit", new { id = newceleb.Id }));
            }
            CelebManager.Edit(newceleb);
            return(RedirectToAction("Edit", new { id = newceleb.Id }));
        }
示例#10
0
        public ActionResult DeleteConfirm(string id)
        {
            if (!CelebManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            string oldAvatar = _db.tbl_Celebrity.SingleOrDefault(c => c.celeb_Id == id).celeb_Avatar;

            if (oldAvatar != "Celeb_1.jpg")
            {
                ImageManager.Delete(Server.MapPath("~/Content/Celeb/" + oldAvatar));
            }
            CelebManager.Delete(id);
            return(RedirectToAction("Index"));
        }
示例#11
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);
            }
            string newId = CelebManager.CreateCeleb(celeb);

            return(RedirectToAction("Edit", new { id = newId }));
        }
示例#12
0
 public ActionResult Reject(RejectViewModel model, string returnurl)
 {
     if (model.Note == "0")
     {
         model.Note = "信息有误";
     }
     else if (model.Note == "1")
     {
         model.Note = "已存在";
     }
     else
     {
         model.Note = "其他";
     }
     CelebManager.Reject(model);
     return(RedirectToLocal(returnurl));
 }
示例#13
0
        public ActionResult Delete(string id, string returnurl)
        {
            if (!CelebManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            //if (id == null)
            //{
            //    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            //    return HttpNotFound();
            //}
            tbl_Celebrity        tblceleb = _db.tbl_Celebrity.SingleOrDefault(s => s.celeb_Id == id);
            ManageCelebViewModel celeb    = new ManageCelebViewModel(tblceleb);

            ViewBag.ReturnUrl = returnurl;
            return(View(celeb));
        }
示例#14
0
        public ActionResult Edit(ManageCelebViewModel 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/Celeb/"), System.IO.Path.GetFileName(file.FileName));
                file.SaveAs(fileName);
                model.Avatar = System.IO.Path.GetFileName(file.FileName);

                string oldAvatar = _db.tbl_Celebrity.SingleOrDefault(c => c.celeb_Id == model.Id).celeb_Avatar;
                if (model.Avatar != oldAvatar && oldAvatar != "Celeb_1.jpg")
                {
                    ImageManager.Delete(Server.MapPath("~/Content/Celeb/" + oldAvatar));
                }
            }
            CelebManager.Edit(model);
            return(RedirectToAction("Edit", new { id = model.Id }));
        }
示例#15
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));
        }
示例#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(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));
        }