Ejemplo n.º 1
0
        public async Task <Basket> UpdateBasket(Basket basket, string userToken)
        {
            var updateBasketUri = Infrastructure.Basket.UpdateBasket(_basketByPassUrl);

            var response = await _apiClient.PostAsync(updateBasketUri, basket, userToken);

            response.EnsureSuccessStatusCode();

            return(basket);
        }
Ejemplo n.º 2
0
        public async Task AddItemToBasket(string userId, BasketItem product, string userToken)
        {
            var basket = await GetBasket(userId, userToken);

            if (basket == null)
            {
                basket = new Basket()
                {
                    BuyerId = userId,
                    Items   = new List <BasketItem>()
                };
            }

            basket.Items.Add(product);

            await UpdateBasket(basket, userToken);
        }
Ejemplo n.º 3
0
        public Order MapBasketToOrder(Basket basket)
        {
            var order = new Order();

            order.Total = 0;

            basket.Items.ForEach(x =>
            {
                order.OrderItems.Add(new OrderItem()
                {
                    ProductId = int.Parse(x.ProductId),

                    PictureUrl  = x.PictureUrl,
                    ProductName = x.ProductName,
                    Units       = x.Quantity,
                    UnitPrice   = x.UnitPrice
                });
                order.Total += (x.Quantity * x.UnitPrice);
            });

            return(order);
        }