Exemplo n.º 1
0
 public static void UpdateOrSaveService(Service serviceToEdit)
 {
     using (var context = new HBGDatorServiceContext())
     {
         Service serviceExisting = context.Services.Where(n => n.ID == serviceToEdit.ID).FirstOrDefault();
         if (serviceExisting == null)
         {
             context.Services.Add(serviceToEdit);
             context.SaveChanges();
         }
         else
         {
             serviceExisting.Header               = serviceToEdit.Header;
             serviceExisting.Textfield            = serviceToEdit.Textfield;
             context.Entry(serviceExisting).State = EntityState.Modified;
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 2
0
 public static void UpdateOrSaveAbouts(About aboutsToEdit)
 {
     using (var context = new HBGDatorServiceContext())
     {
         About aboutsExisting = context.Abouts.Where(n => n.ID == aboutsToEdit.ID).FirstOrDefault();
         if (aboutsExisting == null)
         {
             context.Abouts.Add(aboutsToEdit);
             context.SaveChanges();
         }
         else
         {
             aboutsExisting.Header               = aboutsToEdit.Header;
             aboutsExisting.Textfield            = aboutsToEdit.Textfield;
             context.Entry(aboutsExisting).State = EntityState.Modified;
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 3
0
 public static void UpdateOrSaveNews(News newsToEdit)
 {
     using (var context = new HBGDatorServiceContext())
     {
         News newsExisting = context.News.Where(n => n.newsID == newsToEdit.newsID).FirstOrDefault();
         if (newsExisting == null)
         {
             context.News.Add(newsToEdit);
             context.SaveChanges();
         }
         else
         {
             newsExisting.newsBody             = newsToEdit.newsBody;
             newsExisting.newsDate             = newsToEdit.newsDate;
             newsExisting.newsTopic            = newsExisting.newsTopic;
             context.Entry(newsExisting).State = EntityState.Modified;
             context.SaveChanges();
         }
     }
 }