Exemple #1
0
        public ActionResult AddHelpPost(hx_td_about_news p, int rootid, string context)
        {
            p            = (hx_td_about_news)Utils.ValidateModelClass(p);
            p.context    = context;
            p.createtime = DateTime.Now;
            p.newimg     = p.newimg.Replace("//", "/");

            p.comm        = 0;
            p.listcomm    = 0;
            p.adminuserid = 0;
            ef.hx_td_about_news.Add(p);
            //ef.SaveChanges();
            string str = "";
            int    i   = ef.SaveChanges();

            if (i > 0)
            {
                CacheRemove.RemoveWebCache("NewsList");

                str = StringAlert.Alert("添加成功!", "/admin/Help/Index?rootid=" + rootid);
            }
            else
            {
                str = StringAlert.Alert("添加失败!", "/admin/Help/Add?rootid=" + rootid);
            }
            return(Content(str, "text/html"));
        }
Exemple #2
0
        public ActionResult DelById(int id, int Page = 1, int rootid = 0, string news_title = "")
        {
            string str = "";

            hx_td_about_news pDel = new hx_td_about_news()
            {
                newid = id
            };

            ef.hx_td_about_news.Attach(pDel);
            ef.hx_td_about_news.Remove(pDel);
            int i = ef.SaveChanges();

            if (i > 0)
            {
                CacheRemove.RemoveWebCache("NewsList");

                str = StringAlert.Alert("帮助中心删除成功!", "/admin/Help/Index?page=" + Page.ToString() + "&rootid=" + rootid.ToString() + "&news_title=" + news_title);
            }
            else
            {
                str = StringAlert.Alert("帮助中心删除失败!", "/admin/Help/Index?page=" + Page.ToString() + "&rootid=" + rootid.ToString() + "&news_title=" + news_title);
            }
            return(Content(str, "text/html"));
        }
Exemple #3
0
        public ActionResult SetCommtate(int id, int state, int commtype)
        {
            string json = "{\"ret\":0,\"msg\":\"操作失败\"}";

            if (id < 1)
            {
                json = "{\"ret\":-1,\"msg\":\"参数错误\"}";
            }
            else
            {
                var i = 0;

                if (commtype == 1)
                {
                    i = ef.hx_td_about_news.Where(a => a.newid == id).Update(a => new hx_td_about_news {
                        comm = state
                    });                                                                                                     //首页推荐
                }
                else
                {
                    i = ef.hx_td_about_news.Where(a => a.newid == id).Update(a => new hx_td_about_news {
                        listcomm = state
                    });                                                                                                         //首页推荐
                }


                if (i > 0)
                {
                    CacheRemove.RemoveWebCache("NewsList");
                    json = "{\"ret\":1,\"msg\":\"操作成功\"}";
                }
            }

            return(Content(json, "text/json"));
        }
Exemple #4
0
        public ActionResult EditHelpPost(hx_td_about_news p, int rootid = 0, int page = 1, string context = "")
        {
            string str = "";

            string[] proNames;

            proNames = new string[] { "News_title", "web_Type_menu_id", "News_Key", "news_Des", "context" };


            p = (hx_td_about_news)Utils.ValidateModelClass(p);

            p.context = context;
            p.newimg  = p.newimg.Replace("//", "/");
            DbEntityEntry entry = ef.Entry <hx_td_about_news>(p);

            entry.State = EntityState.Unchanged;

            foreach (string ProName in proNames)
            {
                entry.Property(ProName).IsModified = true;
            }

            int i = ef.SaveChanges();

            if (i > 0)
            {
                CacheRemove.RemoveWebCache("NewsList");
                str = StringAlert.Alert("帮助中心修改成功!", "/Admin/help/index?page=" + page + "&rootid=" + rootid);
            }
            else
            {
                str = StringAlert.Alert("帮助中心修改失败!", "/admin/help/Edit?id=" + p.newid + "&rootid=" + rootid + "&page=" + page);
            }
            return(Content(str, "text/html"));
        }