Beispiel #1
0
        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);
        }
        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 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 void DisplaySuccessMessage(IBarcodeSystemUI systemUI)
 {
     systemUI.DisplayMessage(output);
 }
 public void Execute(string[] args, IBarcodeSystemUI systemUI, IBarcodeSystemManager systemManager)
 {
     systemUI.Close();
 }
 public void DisplaySuccessMessage(IBarcodeSystemUI systemUI)
 {
     systemUI.DisplayMessage("System closing.\nPress any key to exit the application.");
 }
 public abstract void DisplaySuccessMessage(IBarcodeSystemUI systemUI);
 public abstract void Execute(string[] args, IBarcodeSystemUI systemUI, IBarcodeSystemManager systemManager);
Beispiel #11
0
 public void DisplaySuccessMessage(IBarcodeSystemUI systemUI)
 {
     systemUI.DisplayMessage($"Successfully added {amount} credits to {username}'s account!");
 }