Ejemplo n.º 1
0
        public int BuyItems(List <string> items)
        {
            var    products = _stockService.CheckStockStatus(items);
            double price    = 0;

            Console.WriteLine("--- Your Bucket Items ---");
            foreach (var item in products)
            {
                Console.WriteLine(item.Name + " - " + item.Price);
                price += item.Price;
            }
            Console.WriteLine("-------------");
            Console.WriteLine("Total price = " + price);
            OrderValue = _discountService.ApplyDiscount(this._customerId, price);
            Console.WriteLine("After discount price = " + OrderValue);
            Console.WriteLine("-------------");
            var requestUri = RequestConstants.RequestUri + OrderValue;
            var result     = _paymentGatewayClient.GetAsync(requestUri).Result; //pseudo payment gateway call

            if (result.IsSuccessStatusCode)
            {
                Console.WriteLine("Payment processed successfully");
            }
            else
            {
                LogPaymentFailure(result);
            }

            return(products.Count());
        }
        public Task <HttpResponseMessage> GetAsync(string requestUri)
        {
            var result = _paymentGatewayClient.GetAsync(requestUri);

            return(result);
        }