public bool AddProducttoShoppingcar(ShoppingcartDetails model) { var shoppingcarRepository = new ShoppingcartDetailsRepository(); var productsRepository = new ProductsRepository(); var stock = productsRepository.CheckStock(model.ProductID, model.Quantity); if (stock) { var product = shoppingcarRepository.FindById(model.CustomerID, model.ProductID); if (product == null) { shoppingcarRepository.Create(model); } else { shoppingcarRepository.Update(model); } return(true); } else { return(false); } }
public void UpdateTest() { ShoppingcartDetailsRepository repository = new ShoppingcartDetailsRepository(); ShoppingcartDetails model = new ShoppingcartDetails { CustomerID = 1, ProductID = 1, Quantity = 1 }; repository.Update(model); var shoppingcar = repository.GetAll(); Assert.IsTrue(shoppingcar.Count() > 0); }
public void Update(ShoppingcartDetails model) { var shoppingcarRepository = new ShoppingcartDetailsRepository(); shoppingcarRepository.Update(model); }