示例#1
0
        public ActionResult TextPublish(int id)
        {
            ViewBag.Title = "Text";
            var v = Db.Texts.Find(id);

            v.TextPublishTime = DateTime.Now;
            if (v == null)
            {
                ViewBag.msg = "No Text Found";
                return(View("Text"));
            }


            /*var allPublishText = Db.Texts.Where(x => x.IsPublishNow && x.TextId != id);
             * foreach (var a in allPublishText)
             * {
             *  a.IsPublishNow = false;
             * }*/

            if (v.IsPublishNow)
            {
                ViewBag.msg    = "Text Publish Cancel Successfully";
                v.IsPublishNow = false;
                Db.SaveChanges();
            }
            else
            {
                ViewBag.msg    = "Text Publish Successfully";
                v.IsPublishNow = true;
                Db.SaveChanges();
            }

            TvHub.AddText();
            return(View("Text"));
        }
示例#2
0
        public ActionResult VideoPublish(int id)
        {
            ViewBag.Title = "Video";
            var v = Db.Videos.Find(id);

            if (v == null)
            {
                ViewBag.msg = "No Video Found";
                return(View("Video"));
            }
            if (v.NowPublish)
            {
                ViewBag.msg  = "Video Publish Cancel Successfully";
                v.NowPublish = false;
                Db.SaveChanges();
            }
            else
            {
                ViewBag.msg  = "Video Publish Successfully";
                v.NowPublish = true;
                Db.SaveChanges();
            }

            TvHub.AddPlayList();
            return(View("Video"));
        }