Esempio n. 1
0
 public void Add(NewsItem news)
 {
     using (var db = new NewsItemsContext())
     {
         db.News.Add(news);
         db.SaveChanges();
     }
 }
Esempio n. 2
0
 public void Delete(int Id)
 {
     using (var db = new NewsItemsContext())
     {
         var deleted = db.News.Where(x => x.Id == Id).FirstOrDefault();
         db.News.Remove(deleted);
         db.SaveChanges();
     }
 }
Esempio n. 3
0
 public void Edit(int Id, NewsItem item)
 {
     using (var db = new NewsItemsContext())
     {
         var changed = db.News.Where(x => x.Id == Id).FirstOrDefault();
         changed.Header    = item.Header;
         changed.ImageLink = item.ImageLink;
         changed.Text      = item.Text;
         db.SaveChanges();
     }
 }