Пример #1
0
 private void UserInformation(string username)
 {
     try
     {
         User user = _system.GetUserByUsername(username);
         _ui.DisplayUserInfo(user);
     }
     catch (UserNotFoundException ex)
     {
         _ui.DisplayUserNotFound(ex.Username);
     }
 }
Пример #2
0
        public SystemController(ILineSystemUI ui, ILineSystem lineSystem)
        {
            this._ui     = ui;
            this._system = lineSystem;

            _adminCommands.Add(":quit", (s, i) => ui.Close());
            _adminCommands.Add(":q", (s, i) => ui.Close());
            _adminCommands.Add(":activate", (s, productId) =>
            {
                Product product = _system.GetProductByID(productId);
                product.Active  = true;
                ui.DisplayAdminCommandMessage($"Product {product.Name} is set to active");
            });
            _adminCommands.Add(":deactivate", (s, productId) =>
            {
                Product product = _system.GetProductByID(productId);
                product.Active  = false;
                ui.DisplayAdminCommandMessage($"Product {product.Name} is set to deactive");
            });
            _adminCommands.Add(":crediton", (s, productId) =>
            {
                Product product             = _system.GetProductByID(productId);
                product.CanBeBoughtOnCredit = true;
                ui.DisplayAdminCommandMessage($"Product {product.Name} can now be bought on credits");
            });
            _adminCommands.Add(":creditoff", (s, productId) =>
            {
                Product product             = _system.GetProductByID(productId);
                product.CanBeBoughtOnCredit = false;
                ui.DisplayAdminCommandMessage($"Product {product.Name} cannot be bought on credit now");
            });
            _adminCommands.Add(":addcredits", (username, amount) =>
            {
                User user = _system.GetUserByUsername(username);
                _system.AddCreditsToAccount(user, amount);
                ui.DisplayAdminCommandMessage($"{amount}DDK was added to {user.Username}'s account");
            });

            this._ui.CommandEntered += Ui_CommandEntered;
        }