Example #1
0
 public void Insert(Website website)
 {
     using (DBEFContext db = new DBEFContext())
     {
         db.Websites.Add(website);
         db.SaveChanges();
     }
 }
Example #2
0
 public void Delete(int id)
 {
     using (DBEFContext db = new DBEFContext())
     {
         var website = db.Websites.Find(id);
         db.Websites.Remove(website);
         db.SaveChanges();
     }
 }
Example #3
0
        public List <Website> Select()
        {
            List <Website> websites;

            using (DBEFContext db = new DBEFContext())
            {
                websites = db.Websites.ToList();
            }
            return(websites);
        }
Example #4
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();
     }
 }