public void DeleteFromCart(VendorIngredientItem item)
        {
            using (var currentContext = new PizzaSericeContext())
            {
                var cartItem = currentContext.CartIngredients
                    .Where(x => x.VendorIngredient.Vendor.Name == item.VendorName && x.VendorIngredient.Ingredient.Name == item.IngredientName).FirstOrDefault();
                cartItem.VendorIngredient = currentContext.VendorIngredients.Where(x => x.Id == cartItem.VendorIngredientId).FirstOrDefault();

                if ( cartItem.Count > 1)
                    cartItem.Count -= 1;
                else
                    currentContext.CartIngredients.Remove(cartItem);

                currentContext.SaveChanges();
            }
        }
Example #2
0
 public void DeleteFromCart(VendorIngredientItem item)
 {
     CartIngredientsRepository.Instance.DeleteFromCart(item);
 }