示例#1
0
 public int UpdatePost(JObject post)
 {
     try
     {
         var posttitle = post["title"].ToString();
         while (posttitle.Contains("  "))
         {
             posttitle.Replace("  ", " ");
         }
         posttitle = TienIchController.RemoveUnicode(posttitle);
         posttitle = posttitle.Replace(" ", "-");
         var data = db.Tins.Find(post["id"]);
         data.TieuDe          = post["title"].ToString();
         data.TieuDe_KhongDau = posttitle;
         data.urlHinh         = post["image"].ToString();
         data.idTL            = (int)post["cate"];
         data.idLT            = (int)post["subcate"];
         data.TinNoiBat       = (byte)post["hot"];
         data.TomTat          = post["summary"].ToString();
         data.AnHien          = (byte)post["active"];
         data.Content         = post["content"].ToString();
         db.SaveChanges();
         return(1);
     }
     catch (Exception)
     {
         return(0);
     }
 }
 public int InsertSubCate(JObject cate)
 {
     try
     {
         var catetitle = cate["catename"].ToString();
         while (catetitle.Contains("  "))
         {
             catetitle.Replace("  ", " ");
         }
         catetitle = TienIchController.RemoveUnicode(catetitle);
         catetitle = catetitle.Replace(" ", "-");
         LoaiTin data = new LoaiTin();
         data.Ten          = cate["catename"].ToString();
         data.Ten_KhongDau = catetitle;
         data.AnHien       = (byte)cate["cateactive"];
         data.ThuTu        = (byte)cate["catenumber"];
         data.idTL         = (int)cate["cate"];
         db.LoaiTins.Add(data);
         db.SaveChanges();
         return(1);
     }
     catch (Exception)
     {
         return(0);
     }
 }
示例#3
0
 public int UpdateCate(JObject cate)
 {
     try
     {
         var catetitle = cate["catename"].ToString();
         while (catetitle.Contains("  "))
         {
             catetitle.Replace("  ", " ");
         }
         catetitle = TienIchController.RemoveUnicode(catetitle);
         catetitle = catetitle.Replace(" ", "-");
         var data = db.TheLoais.Find(cate["cateid"]);
         data.TenTL          = cate["catename"].ToString();
         data.TenTL_KhongDau = catetitle;
         data.AnHien         = (byte)cate["cateactive"];
         data.ThuTu          = (int)cate["catenumber"];
         db.SaveChanges();
         return(1);
     }
     catch (Exception)
     {
         return(0);
     }
 }