Example #1
0
        public static bool UpdateContents(int id, string context)
        {
            using (Entities db = new Entities())
            {
                db.Configuration.ProxyCreationEnabled = false;
                var model = db.ht_help.Find(id);

                if (model != null)
                {
                    model.contents    = context;
                    model.update_time = DateTime.Now;
                }
                else
                {
                    model             = new ht_help();
                    model.title       = "发布须知";
                    model.update_time = DateTime.Now;
                    model.contents    = context;
                    model.add_time    = DateTime.Now;
                    model.sort        = 1;
                    db.ht_help.Add(model);
                }
                if (db.SaveChanges() > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Example #2
0
 private bool DoAdd()
 {
     try
     {
         ht_help model = new ht_help();
         model.title       = title.Text;
         model.contents    = contents.Text;
         model.sort        = Convert.ToInt32(sort.Text);
         model.update_time = DateTime.Now;
         db.ht_help.Add(model);
         db.SaveChanges();
         AddAdminLog(HTEnums.ActionEnum.Add.ToString(), "添加帮助中心:" + model.title); //记录日志
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }