예제 #1
0
 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;
 }
예제 #2
0
 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");
     }
 }