예제 #1
0
        public void SaveToDataBase(ObservableCollection <ListSite> listSites)
        {
            foreach (var item in listSites)
            {
                var products = new List <ListSite>
                {
                    new ListSite {
                        Image = item.Image, Link = item.Link, Name = item.Name, Price = item.Price
                    }
                };

                using (ListSiteContext context = new ListSiteContext())
                {
                    context.ListSites.AddRange(products);
                    context.SaveChanges();
                }
            }
        }
예제 #2
0
        public void ViewHistorySearch()
        {
            List <ListSite> historyProducts = new List <ListSite>();

            using (ListSiteContext dbContext = new ListSiteContext())
            {
                foreach (var col in dbContext.ListSites.ToList())
                {
                    ListSite element = new ListSite();
                    element.ListSiteID = col.ListSiteID;
                    element.Image      = col.Image;
                    element.Link       = col.Link;
                    element.Name       = col.Name;
                    element.Price      = col.Price;

                    historyProducts.Add(element);
                }
            }
            Products = new ObservableCollection <ListSite>(historyProducts);
        }