public void Delete(string id) { using (HalloweenContext data = new HalloweenContext()) { data.Set <ProductViewModel>().Remove(Get(id)); data.SaveChanges(); } }
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); } }
//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); } }
public ProductViewModel Get(string id) { using (HalloweenContext data = new HalloweenContext()) return(data.Set <ProductViewModel>().Find(id)); }