Ejemplo n.º 1
0
        //------------------------------------------------------------------------------------------------------- Service

        public static List <Service> GetAllServices(int nrToGet = 4)
        {
            using (var context = new HBGDatorServiceContext())
            {
                return(context.Services.OrderByDescending(d => d.ID).Take(nrToGet).ToList());
            }
        }
Ejemplo n.º 2
0
 public static Service GetServiceById(int idToGet)
 {
     using (var context = new HBGDatorServiceContext())
     {
         return(context.Services.Where(n => n.ID == idToGet).FirstOrDefault());
     }
 }
Ejemplo n.º 3
0
 public static IEnumerable <News> GetNewsList()
 {
     using (var context = new HBGDatorServiceContext())
     {
         return(context.News.OrderByDescending(d => d.newsDate).ToList());
     }
 }
Ejemplo n.º 4
0
        //------------------------------------------------------------------------------------------------------- Users/Admins

        public static List <UserAccount> GetAllUsers(int nrToGet)
        {
            using (var context = new HBGDatorServiceContext())
            {
                return(context.UserAccount.OrderByDescending(d => d.FirstName).Take(nrToGet).ToList());
            }
        }
Ejemplo n.º 5
0
 public static News GetNewsById(int idToGet)
 {
     using (var context = new HBGDatorServiceContext())
     {
         return(context.News.Where(n => n.newsID == idToGet).FirstOrDefault());
     }
 }
Ejemplo n.º 6
0
        //------------------------------------------------------------------------------------------------------- Price

        //Finns inte ännu.

        //------------------------------------------------------------------------------------------------------- News

        public static List <News> GetLatestNews(int nrToGet = 4)
        {
            using (var context = new HBGDatorServiceContext())
            {
                return(context.News.OrderByDescending(d => d.newsDate).Take(nrToGet).ToList());
            }
        }
Ejemplo n.º 7
0
 public static IEnumerable <About> GetAboutList()
 {
     using (var context = new HBGDatorServiceContext())
     {
         return(context.Abouts.OrderByDescending(d => d.ID).ToList());
     }
 }
Ejemplo n.º 8
0
 public static void DeleteSlideShowImage(int id)
 {
     using (var context = new HBGDatorServiceContext())
     {
         var image = context.SlideShowImages.Find(id);
         context.SlideShowImages.Remove(image);
         context.SaveChanges();
     }
 }
Ejemplo n.º 9
0
 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();
     }
 }
Ejemplo n.º 10
0
        //------------------------------------------------------------------------------------------------------- SlideShow

        public static List <ImageModel> GetAllSlideShowImages()
        {
            using (var context = new HBGDatorServiceContext())
            {
                return((from i in context.SlideShowImages
                        where i.Active == true && i.ImagePath.StartsWith(@"~/SlideImages/")
                        select(new ImageModel
                {
                    ID = i.ID,
                    Active = i.Active,
                    ImagePath = i.ImagePath,
                    FileName = i.FileName
                })).ToList());
            }
        }
Ejemplo n.º 11
0
 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;
         }
     }
 }
Ejemplo n.º 12
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();
         }
     }
 }
Ejemplo n.º 13
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();
         }
     }
 }
Ejemplo n.º 14
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();
         }
     }
 }