public static void DeleteSlideShowImage(int id) { using (var context = new HBGDatorServiceContext()) { var image = context.SlideShowImages.Find(id); context.SlideShowImages.Remove(image); context.SaveChanges(); } }
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(); } } }
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(); } } }
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(); } } }
public static void AddNewSlideShowFile(string fileName, string path) { using (var context = new HBGDatorServiceContext()) { context.SlideShowImages.Add(new SlideShowImage() { FileName = fileName, ImagePath = path, Active = true } ); context.SaveChanges(); } }
public static void DeleteNews(int id) { using (var context = new HBGDatorServiceContext()) { News toRemove = context.News.Where(n => n.newsID == id).FirstOrDefault(); if (toRemove != null) { context.News.Remove(toRemove); context.SaveChanges(); } else { return; } } }