Пример #1
0
        public async Task <RedirectToActionResult> AddToCartAsync(Guid id)
        {
            var shoppingCart = await _shoppingCartRepository.GetCartAsync();

            Pie  pie  = _pieRepository.GetPieById(id);
            Cake cake = _cakeRepository.GetCakeById(id);

            if (pie != null)
            {
                _shoppingCartRepository.AddToCart(pie, 1);
            }
            else if (cake != null)
            {
                _shoppingCartRepository.AddToCart(cake, 1);
            }
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public async Task AddToCart(int id)
        {
            int quantity        = 1;
            var selectedProduct = _productManager.GetProductById(id);
            await _ammountRepository.RemoveOne(id);

            await _shoppingCartRepository.AddToCart(selectedProduct, quantity);
        }
Пример #3
0
        public async Task <ShoppingCart> AddToCart(ShoppingCart shoppingCart)
        {
            if (!_shoppingCartValidator.IsShoppingCartValid(shoppingCart))
            {
                throw new Exception("Shopping Cart already contains same configuration Laptop, please add different configuration" + shoppingCart);
            }

            return(await _shoppingCartRepository.AddToCart(shoppingCart));
        }
Пример #4
0
        public RedirectToActionResult AddToShoppingCart(int pieId)
        {
            var selectedPie = _pieRepository.AllPies.FirstOrDefault(p => p.Id == pieId);

            if (selectedPie != null)
            {
                _shoppingCartRepository.AddToCart(selectedPie, 1);
            }
            return(RedirectToAction("Index"));
        }
        public RedirectResult AddToShoppingCart(int pieId)
        {
            var selectedPie = _pieRepository.ActivePies.FirstOrDefault(p => p.PieId == pieId);

            if (selectedPie != null)
            {
                _cartRepository.AddToCart(selectedPie, 1);
            }
            return(Redirect("/cart"));
        }
Пример #6
0
        public async Task <SimpleResponse> AddToCart([FromHeader] string Authorization,
                                                     [FromBody] CartRequest request)
        {
            var success = await Repository.AddToCart(request.productId, request.deviceId, request.userId);

            return(new SimpleResponse()
            {
                Success = success
            });
        }
        public async Task <RedirectToActionResult> AddToShoppingCart(int id)
        {
            var selectedCake = await _cakeRepository.Get(id);

            if (selectedCake != null)
            {
                _shoppingCartRepository.AddToCart(selectedCake, 1);
            }

            return(RedirectToAction("GetCartItems"));
        }
Пример #8
0
        public IActionResult AddToShoppingCart(int PieID)
        {
            var pie = pieRepository.GetPieById(PieID);

            if (!pie.Equals(null))
            {
                shoppingCart.AddToCart(pie, 1);
            }



            return(RedirectToAction("Index"));
        }
Пример #9
0
        public ActionResult AddToCart(int advertisementId)
        {
            string        accountId = HttpContext.Session.GetString("username"); //session
            ShoppingCart  cart      = _shoppingCartRepository.GetShoppingCart(accountId);
            Advertisement ad        = _advertisementRepository.GetAdvertisement(advertisementId);

            ShoppingCartItem item = new ShoppingCartItem {
                ShoppingCartId = cart, ad = ad
            };

            _shoppingCartRepository.AddToCart(ad, cart);
            TempData["success"] = "The card has been succesfully added to your cart";
            return(RedirectToAction("list", "Advertisement"));
        }
Пример #10
0
        public IActionResult AddToShoppingCart(int drinkId)
        {
            var drink = _drinkRepository.SingleOrDefault(x => x.Id == drinkId);

            if (drink != null)
            {
                _repository.AddToCart(drinkId, 1);
            }
            else
            {
                Response.StatusCode = 404;
                return(View("DrinkNotFound", drinkId));
            }

            return(RedirectToAction("Index"));
        }
Пример #11
0
        public bool AddToShoppingCart(string id)
        {
            try
            {
                string cartId  = GetCart(services);
                var    product = productRepository.All.Where(d => d.Id == id).FirstOrDefault();
                if (product != null)
                {
                    shoppingCart.AddToCart(product, cartId);
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
Пример #12
0
 public async Task AddToCart(Product product, int amount)
 {
     await _shoppingCartRepository.AddToCart(product, amount);
 }