public void Checkout(Order order) { if (order.Products.Count > 0) { _log.LogInformation("Starting Transaction."); Hashtable orderHash = HashOrder(order); _log.LogInformation("Order processed. Subtotal: ${OrderSubtotal}, Discount: ${OrderDiscount}, Total: ${OrderTotal}.", order.SubTotal, order.TotalDiscount, (order.SubTotal - order.TotalDiscount)); _log.LogInformation("Printing receipt."); _kioskPrinter.PrintReceipt(orderHash); _log.LogInformation("Transaction complete."); } else { _log.LogWarning("Checkout attempted with empty order"); _kioskPrinter.PrintLineToConsole("Unable to checkout empty order."); } }
public List <Product> ScanItems(string[] checkoutItemArray) { _log.LogInformation("Scanning items."); checkoutItemArray = FormatItemArray(checkoutItemArray); Hashtable productCataglog = _dataAccessService.GetProductCatalog(); List <Product> productsToCheckout = new List <Product>(); foreach (string checkoutItem in checkoutItemArray) { if (productCataglog.ContainsKey(checkoutItem)) { productsToCheckout.Add((Product)productCataglog[checkoutItem]); _log.LogInformation("Scanned item [{ScannedItem}].", checkoutItem); } else { _log.LogWarning("Unable to find item [{UnknownItem}] in product catalog.", checkoutItem); _kioskPrinter.PrintLineToConsole($"Unable to find item [{checkoutItem}] in product catalog."); } } _log.LogInformation("Scanning complete."); return(productsToCheckout); }