コード例 #1
0
        private async Task OnOptionSelected(IDialogContext context, IAwaitable <string> result)
        {
            var message = await result;

            if (message == EndConfiguration)
            {
                context.Done(new object());
                return;
            }

            if (message == AddNotification)
            {
                context.Call(new PromptTimeDialog("Podaj godzinê (np. 8:30) o której chcesz byæ informowany o ew. przekroczeniach norm."), OnAddNofiticationTimeProvided);
            }
            else
            {
                var notifications = await _accessor.GetNotificationTimes(_conversationId);

                foreach (var notification in notifications)
                {
                    if (message == $"Usuñ powiadomienie o {notification}")
                    {
                        await context.SendTypingMessage();

                        await _accessor.DeleteNotificationTime(_conversationId, notification);

                        await context.PostAsync($"Usuniêto powiadomienie o {notification}");

                        break;
                    }
                }

                await ShowMenu(context);
            }
        }
コード例 #2
0
        private async Task OnOptionSelected(IDialogContext context, IAwaitable <string> result)
        {
            var message = await result;

            switch (message)
            {
            case EndConfiguration:
                context.Done(new object());
                return;

            case AddNotification:
                context.Call(new PromptTimeDialog("Podaj godzinę (np. 8:30) o której chcesz być informowany o ew. przekroczeniach norm."), OnAddNofiticationTimeProvided);
                break;

            default:
                var notifications = await _accessor.GetNotificationTimes(context.Activity.Conversation.Id);

                foreach (var notification in notifications)
                {
                    // not so good...
                    if (message != string.Format(DeleteConfigurationTemplate, notification))
                    {
                        continue;
                    }

                    await context.SendTypingMessage();

                    await _accessor.DeleteNotificationTime(context.Activity.Conversation.Id, notification);

                    await context.PostAsync($"Usunięto powiadomienie o {notification}");

                    break;
                }

                await ShowMenu(context);

                break;
            }
        }