public override ITransaction ToTransaction(IBarcodeSystemManager barcodeSystemManager) { IUser user = barcodeSystemManager.GetUserByUsername(Username); IProduct product = barcodeSystemManager.GetProductById(productId); return(new BuyTransaction(Id, user, product, Date, count)); }
public void Execute(string[] args, IBarcodeSystemUI systemUI, IBarcodeSystemManager systemManager) { username = args[0]; amount = int.Parse(args[1]); IUser user = systemManager.GetUserByUsername(username); systemManager.AddCreditsToAccount(user, amount); }
public BarcodeSystemController(IBarcodeSystemManager systemManager, IBarcodeSystemUI systemUI) { this.systemManager = systemManager; this.systemUI = systemUI; adminCommands = new Dictionary <string, IAdminCommand>() { { "addcredits", new AddCreditsToUserCommand() }, { "qa", new ExitCommand() }, { "activate", new SetProductActiveCommand(true) }, { "deactivate", new SetProductActiveCommand(false) }, { "crediton", new SetProductCanBeBoughtOnCredit(true) }, { "creditoff", new SetProductCanBeBoughtOnCredit(false) } }; systemUI.CommandEntered += ParseCommand; }
public override void Execute(string[] args, IBarcodeSystemUI systemUI, IBarcodeSystemManager systemManager) { product = GetProduct(args[0], systemUI, systemManager); if (active == product.IsActive) { output = active ? $"Product {product.Name} is already active!" : $"Product {product.Name} is already inactive!"; } else { output = active ? $"Product {product.Name} is now active." : $"Product {product.Name} is no longer active."; product.IsActive = active; } }
public void Execute(string[] args, IBarcodeSystemUI systemUI, IBarcodeSystemManager systemManager) { uint productId = uint.Parse(args[0]); product = systemManager.GetProductById(productId); if (canBeBoughtOnCredit == product.CanBeBoughtOnCredit) { output = canBeBoughtOnCredit ? $"Product {product.Name} can already be bought on credit!" : $"Product {product.Name} already cannot be bought on credit!"; } else { output = canBeBoughtOnCredit ? $"Product {product.Name} can now be bought on credit." : $"Product {product.Name} can no longer be bought on credit."; product.CanBeBoughtOnCredit = canBeBoughtOnCredit; } }
public abstract ITransaction ToTransaction(IBarcodeSystemManager barcodeSystemManager);
public override ITransaction ToTransaction(IBarcodeSystemManager barcodeSystemManager) { IUser user = barcodeSystemManager.GetUserByUsername(Username); return(new InsertCashTransaction(Id, user, Date, Amount)); }
public void Execute(string[] args, IBarcodeSystemUI systemUI, IBarcodeSystemManager systemManager) { systemUI.Close(); }
protected IProduct GetProduct(string productIdString, IBarcodeSystemUI systemUI, IBarcodeSystemManager systemManager) { if (!uint.TryParse(productIdString, out uint productId)) { systemUI.DisplayProductNotFound(productIdString); return(null); } return(systemManager.GetProductById(productId)); }
public abstract void Execute(string[] args, IBarcodeSystemUI systemUI, IBarcodeSystemManager systemManager);
public BarcodeSystemUI(IBarcodeSystemManager systemManager) { this.systemManager = systemManager; }