示例#1
0
 public ActionResult Creat(News news)
 {
     news.EscapeStringName = EscapeUrl.UnicodeParse(news.Title);
     if (ModelState.IsValid) {
     dbContext.Newss.Add(news);
     dbContext.SaveChanges();
     int index = 0;
     index = dbContext.Newss.OrderBy(x => x.Title).ToList().IndexOf(news);
     return Json(400, "Lỗi tạo tin tức");
     }
     return new HttpStatusCodeResult(400, "Lỗi tạo tin tức");
 }
示例#2
0
 public ActionResult UpdateNews(News news)
 {
     news.EscapeStringName = EscapeUrl.UnicodeParse(news.Title);
     if (ModelState.IsValid)
     {
         dbContext.Entry(news).State = EntityState.Modified;
         dbContext.SaveChanges();
         return null;
     }
     else
     {
         return new HttpStatusCodeResult(400, "Lỗi update tin tức");
     }
 }