Пример #1
0
 public void Insert(Website website)
 {
     using (DBEFContext db = new DBEFContext())
     {
         db.Websites.Add(website);
         db.SaveChanges();
     }
 }
Пример #2
0
 public void Delete(int id)
 {
     using (DBEFContext db = new DBEFContext())
     {
         var website = db.Websites.Find(id);
         db.Websites.Remove(website);
         db.SaveChanges();
     }
 }
Пример #3
0
 public void Change(int id, string site, string url, int gap)
 {
     using (DBEFContext db = new DBEFContext())
     {
         var website = db.Websites.Find(id);
         if (!string.IsNullOrEmpty(site))
         {
             website.Site = site;
         }
         if (!string.IsNullOrEmpty(url))
         {
             website.URL = url;
         }
         if (gap != 0)
         {
             website.Gap = gap;
         }
         db.SaveChanges();
     }
 }