public int Creat(News news) { dbContext.Newss.Add(news); dbContext.SaveChanges(); int index = 0; index = dbContext.Newss.OrderBy(x => x.Title).ToList().IndexOf(news); return index; }
public ActionResult UpdateNews(News news) { if (ModelState.IsValid) { dbContext.Entry(news).State = EntityState.Modified; dbContext.SaveChanges(); return null; } else { return new HttpStatusCodeResult(400, "Custom Error Message 2"); } }