public PurchaseResult(IPurchaseReport purchaseReport) { if (purchaseReport == null) { throw new ArgumentNullException(nameof(purchaseReport)); } Report = purchaseReport; }
public ICommandResult Execute() { this.ShowStock(); Console.Write("Enter item name: "); string itemName = Console.ReadLine(); IPurchaseReport report = this.appServices.Purchase(itemName); return(new PurchaseResult(report)); }
public void Execute() { this.ShowStock(); Console.Write("Enter item name: "); string itemName = Console.ReadLine(); IPurchaseReport report = this.appServices.Purchase(itemName); DisplayReport(report); }
static TPurchaseReport Cast <TPurchaseReport>(ICommandResult cmdResult) where TPurchaseReport : IPurchaseReport { PurchaseResult purchaseResult = cmdResult as PurchaseResult; if (purchaseResult == null) { return(default(TPurchaseReport)); } IPurchaseReport report = purchaseResult.Report; return((TPurchaseReport)report); }
private IView LocatePurchaseView(IPurchaseReport report) { if (report == null) { return(new EmptyView()); } Type reportType = report.GetType(); if (reportType == typeof(FailedPurchase)) { return(new FailedPurchaseView()); } if (reportType == typeof(NotEnoughMoney)) { return(new NotEnoughMoneyView(report as NotEnoughMoney)); } if (reportType == typeof(NotRegistered)) { return(new NotRegisteredView(report as NotRegistered)); } if (reportType == typeof(NotSignedIn)) { return(new NotSignedInView()); } if (reportType == typeof(ProductNotFound)) { return(new ProductNotFoundView(report as ProductNotFound)); } if (reportType == typeof(Receipt)) { return(new ReceiptView(report as Receipt)); } return(new EmptyView()); }
private void DisplayReport(IPurchaseReport report) { Console.WriteLine(report.ToUiText()); }