Ejemplo n.º 1
0
        public async Task <IActionResult> clearCart()
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var cartVm = await _cartApiClient.GetCartByUser(userId);

            var orderVm = await _orderApiClient.GetOrderByUser(userId);

            var     lstProduct  = new List <OrderDetailVm>();
            OrderVm od          = new();
            int     y           = orderVm.Count();
            var     lstCartItem = cartVm.cartItemVms.ToList();

            if (lstCartItem.Count > 0)
            {
                foreach (var x in lstCartItem)
                {
                    var pVm = new OrderDetailVm()
                    {
                    };
                    pVm.ProductId = x.productVm.Id;
                    pVm.Quantity  = x.Quantity;
                    pVm.UnitPrice = x.productVm.Price;
                    pVm.OrderId   = y + 1;

                    lstProduct.Add(pVm);
                }
                ;
            }
            await _cartApiClient.clearCart(userId);

            await _orderApiClient.CreateOrder(userId, lstProduct);

            return(RedirectToAction("Index", "Order"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var orders = await _orderApiClient.GetOrderByUser(userId);

            //Set url backend for image

            return(View(orders));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Index()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("SignIn", "Account"));
            }
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var orders = await _orderApiClient.GetOrderByUser(userId);

            return(View(orders));
        }