public void updateProductInCard(int cardId, int productId) { DataClasses1DataContext db = new DataClasses1DataContext(); ProductCard productToDelete = (from p in db.ProductCards where cardId == p.CardId select p).Single(); Product product = (from p in db.Products where productId == p.ProductId select p).Single(); product.Quantity -= Convert.ToInt32(productToDelete.Quantity); // db.ProductCards.DeleteOnSubmit(productToDelete); db.SubmitChanges(); }
//---------------------------Card functionality ------------------------------------------ public void addProductToCard(int productId, int ProductTypeId, int userId, int quantity, decimal price) { DataClasses1DataContext db = new DataClasses1DataContext(); ProductCard card = new ProductCard(); card.ProductId = productId; card.ProductTypeId = ProductTypeId; card.DateTime = DateTime.Now; card.UserId = userId; card.Quantity = quantity; card.productPrice = price; card.isRemoved = "false"; db.ProductCards.InsertOnSubmit(card); db.SubmitChanges(); }
partial void UpdateProductCard(ProductCard instance);
partial void DeleteProductCard(ProductCard instance);
partial void InsertProductCard(ProductCard instance);