Ejemplo n.º 1
0
        public async Task <int> AddCartDetailAsync(CartDetailModel cartDetailModel)
        {
            _dbContext.CartDetailModels.Add(cartDetailModel);
            await _dbContext.SaveChangesAsync();

            return(cartDetailModel.CartDetailId);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Confirm(CartDetailModel order)
        {
            var actionData = this.GetActionData();

            switch (actionData?.ActionName)
            {
            case Actions.Continue:
                //var orderId = await CartService.SubmitCartOrderAsync(GetUserId());
                return(RedirectToAction("Square"));

            case Actions.Back:
                return(RedirectToAction("Shipping"));

            default:
                var svcOrder = await CartUserService.GetCartOrderAsync(GetUserId());

                if (svcOrder == null)
                {
                    AddFeedbackMessage(FeedbackMessageTypes.Informational, "Your shopping cart is empty.");
                    return(RedirectToAction("Index", "Order"));
                }

                var model = ModelFactory.CreateCartDetailModel(svcOrder);
                return(View(model));
            }
        }
Ejemplo n.º 3
0
        public ActionResult MyCart()
        {
            var userId = _db.AppUsers.SingleOrDefault(x => x.Email == User.Identity.Name).UserId;
            var items  = _db.ShoppingCarts.Include(x => x.Product).Where(x => x.UserId == userId).ToList();
            var model  = new CartDetailModel(items);

            return(View(model));
        }
Ejemplo n.º 4
0
        public static CartDetailModel MockCartDetailModel()
        {
            CartDetailModel cartDetailModel = new CartDetailModel()
            {
                ProductId       = MockProductModel().ProductId,
                ProductQuantity = 3
            };

            return(cartDetailModel);
        }
Ejemplo n.º 5
0
        public async Task <int> AddItemAsync(int cartId, ProductDTO product, int quantity)
        {
            CartDetailDTO cartDetailDTO = new CartDetailDTO()
            {
                CartId          = cartId,
                ProductId       = product.ProductId,
                ProductQuantity = quantity
            };
            CartDetailModel cartDetailModel = _mapper.Map <CartDetailModel>(cartDetailDTO);

            return(await _cartEFService.AddCartDetailAsync(cartDetailModel));
        }
Ejemplo n.º 6
0
        public IActionResult CartDetail()
        {
            ShoppingCart cart  = PageMaster.GetShoppingCart();
            var          model = new CartDetailModel()
            {
                Cart           = cart,
                CartItems      = Repository.GetCartItems(cart),
                CartTotalPrice = Repository.GetCartTotalPrice(cart)
            };

            ViewBag.CountCartItems = cart.CartProducts.Count();
            return(View(model));
        }