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 Order BuildOrder(Product product, int quantity, string promoCode) { var order = new Order(product, quantity); _discountService.ApplyDiscount(order); _promoCodeService.ApplyPromoCode(promoCode, order); return(order); }
public async Task <List <Book> > GetAllBooksAsync() { try { var books = await _repo.GetAllBooksAsync(); _discountService.ApplyDiscount(books.Cast <AbstractItem>().ToList()); return(books.ToList()); } catch (DataException e) { _logger.Error(e.Message); throw new DataException(e.Message); } }
public decimal GetTotalPrice() { decimal totalPrice = 0.0m; if (_basket != null) { foreach (var product in Basket.Products) { totalPrice += product.Price.Amount; } } _discountService.ApplyDiscount(); return(totalPrice); }
public async Task <List <AbstractItem> > SearchItemsByTitle(string value) { try { var items = await _repo.GetItemsByTitleAsync(value); var itemList = items.ToList(); _discountService.ApplyDiscount(itemList); return(itemList); } catch (DataException e) { _logger.Error(e.Message); throw new Exception(e.Message); } }
public int BuyItems(List <string> items) { var products = _stockRepository.CheckStockStatus(items); double price = 0; foreach (var item in products) { price += item.Price; } OrderValue = _discountService.ApplyDiscount(price); var requestUri = "http://www.google.com/search?q=" + OrderValue; var result = _paymentGateWay.GetAsync(requestUri).Result; //pseudo payment gateway call if (result.IsSuccessStatusCode) { Console.WriteLine("Payment processed successfully"); } else { LogPaymentFailure(result); } return(products.Count()); }