Пример #1
0
        private void AskForServiceState(ActionOnItem actionOnItem, ITurnContext turnContext)
        {
            if (!IsValidServiceId(actionOnItem.itemName))
            {
                OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.emptyServicePhrases));
                return;
            }
            QueuedItem item = GetQueuedService(actionOnItem.itemName);

            if (item != null)
            {
                ShowServiceState(item.Id, turnContext);
            }
            else
            {
                OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.emptyServicePhrases));
            }
        }
Пример #2
0
        private void RequestService(ActionOnItem actionOnItem, ITurnContext turnContext)
        {
            if (!IsValidServiceId(actionOnItem.itemName))
            {
                OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.emptyServicePhrases));
                return;
            }
            QueuedItem item = GetQueuedService(actionOnItem.itemName);

            if (item != null)
            {
                AddUserToServiceQueue(turnContext.Activity.From.Name, item, turnContext);
            }
            else
            {
                CreateQueuedService(turnContext.Activity.From.Name, actionOnItem.itemName);
                OperationFinished?.Invoke(turnContext, $"{actionOnItem.itemName} ha sido reservado por {turnContext.Activity.From.Name}");
            }
        }
Пример #3
0
        private void SetServiceFree(ActionOnItem actionOnItem, ITurnContext turnContext)
        {
            if (!IsValidServiceId(actionOnItem.itemName))
            {
                OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.emptyServicePhrases));
                return;
            }
            QueuedItem item = GetQueuedService(actionOnItem.itemName);

            if (item == null)
            {
                OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.emptyServicePhrases));
                return;
            }
            if (item.IsCurrentOwner(turnContext.Activity.From.Name))
            {
                RemoveOwnerFromService(item, turnContext);
                return;
            }
            OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.authorizationErrors));
        }
Пример #4
0
        public static ActionOnItem GetActionService(List <string> texts)
        {
            ActionOnItem actionOnItem = new ActionOnItem();

            foreach (string t in texts)
            {
                if (ConversationWords.requestWords.Contains(t))
                {
                    actionOnItem.actionType = ActionType.RequestItem;
                }
                else if (ConversationWords.freeWords.Contains(t))
                {
                    actionOnItem.actionType = ActionType.SetItemFree;
                }
                else if (ConversationWords.askForServiceStateWords.Contains(t))
                {
                    actionOnItem.actionType = ActionType.AskForItemState;
                }
                int requestIndex = texts.IndexOf(t);
                actionOnItem.itemName = texts[requestIndex + 1];
                return(actionOnItem);
            }
            return(actionOnItem);
        }
Пример #5
0
        private void ProcessAction(ActionOnItem actionOnItem, ITurnContext turnContext)
        {
            switch (actionOnItem.actionType)
            {
            case ActionType.NoAction:
                OperationFinished?.Invoke(turnContext, ConversationWords.errorParsingMessage);
                return;

            case ActionType.RequestItem:
                RequestService(actionOnItem, turnContext);
                break;

            case ActionType.AskForItemState:
                AskForServiceState(actionOnItem, turnContext);
                break;

            case ActionType.SetItemFree:
                SetServiceFree(actionOnItem, turnContext);
                break;

            default:
                break;
            }
        }