示例#1
0
        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);
            }
        }
示例#2
0
        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);
        }
示例#3
0
        public void Update(ShoppingcartDetails model)
        {
            var shoppingcarRepository = new ShoppingcartDetailsRepository();

            shoppingcarRepository.Update(model);
        }