Пример #1
0
        public async Task<Cart> AddProductToCartAsync(long productId, int quantity = 1, long offerId = 0)
        {
            using (var log = RequestLogger.Current.BeginJungoLog(this))
            {
                try
                {
                    var billboard = await Billboard.GetAsync(Client).ConfigureAwait(false);
                    object parameters;
                    if (quantity > 1 && offerId > 0)
                        parameters = new {productId, quantity, offerId};
                    else if (quantity > 1)
                        parameters = new {productId, quantity};
                    else if (offerId > 0)
                        parameters = new {productId, offerId};
                    else
                        parameters = new {productId};
                    var addProductToCartLink = new AddProductToCartLink
                    {
                        CartUri =
                            Billboard.ResolveTemplate(billboard.Cart, Billboard.Templates.AddProductToCartQuery,
                                parameters)
                    };

                    return await AddProductToCartAsync(addProductToCartLink).ConfigureAwait(false);
                }
                catch (Exception exc)
                {
                    throw log.LogException(exc);
                }
            }
        }
Пример #2
0
 public async Task<Cart> AddProductToCartAsync(AddProductToCartLink addToCartLink)
 {
     using (var log = RequestLogger.Current.BeginJungoLog(this))
     {
         try
         {
             return (await Client.PostAsync<CartResponse>(addToCartLink.CartUri).ConfigureAwait(false)).Cart;
         }
         catch (Exception exc)
         {
             throw log.LogException(exc);
         }
     }
 }