Пример #1
0
        public bool TryExecuteCommand(string command)
        {
            InstructionParser.TryParse(command, out var instruction);
            switch (instruction)
            {
            case DrinkInstruction drinkInstruction:
                _moneyModule.DrinkOrder = drinkInstruction.DrinkType;
                if (_beverageQuantityChecker.IsEmpty(drinkInstruction.DrinkType))
                {
                    _emailNotifier.NotifyMissingDrink(drinkInstruction.DrinkType);
                    Message = "There is not enough water or milk";
                    return(false);
                }
                Message = _moneyModule.GetOrderTotalMessage();
                _moneyModule.RequestMoney();
                if (!_moneyModule.IsOrderPaid())
                {
                    Message = _moneyModule.GetOrderNotPaidMessage();
                    return(false);
                }

                Drink = GetDrink(drinkInstruction);
                return(true);

            case MessageInstruction messageInstruction:
                Message = GetMessage(messageInstruction);
                return(true);

            case ErrorMessageInstruction errorMessageInstruction:
                Message = ErrorMessage(errorMessageInstruction);
                return(false);

            default:
                return(false);
            }
        }