Exemple #1
0
 public void Delete(string id)
 {
     using (HalloweenContext data = new HalloweenContext())
     {
         data.Set <ProductViewModel>().Remove(Get(id));
         data.SaveChanges();
     }
 }
Exemple #2
0
        public Product GetProductByIdFromDataStore(string id)
        {
            using (HalloweenContext data = new HalloweenContext())
            {                                                                         //Get a product from Products of data where ProductID is matched with id parameter
                return(data.Products.Where(p => p.ProductID == id).FirstOrDefault()); //study


                // return data.Products.Find(id);
            }
        }
Exemple #3
0
        //Implement GetAllProductsFromDataStore
        public List <Product> GetAllProductsFromDataStore()
        {
            List <Product> productList = new List <Product>();

            using (HalloweenContext data = new HalloweenContext())
            {  //get all the products from the Collection Products order by name using HalloweenEntities=Halloween;
                productList = data.Products.OrderBy(a => a.Name).ToList();

                return(productList);
            }
        }
Exemple #4
0
 public ProductViewModel Get(string id)
 {
     using (HalloweenContext data = new HalloweenContext())
         return(data.Set <ProductViewModel>().Find(id));
 }