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"); }
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"); } }