Пример #1
0
        public override async Task HandleCommandState(long identifier, string chatState, object message, string data)
        {
            var m    = message as Message;
            var auth = authRepository.GetCurrentAuth(identifier);

            switch (chatState)
            {
            case writeParams:
            {
                if (data == "+")
                {
                    var body = new EventCreatorModel();
                    createEventRepository.SetEventCreatorModel(identifier, body);
                    chatRepository.SetState(identifier, this, writeDate);
                    await((ITelegramBotClient)BotService.Client).SendTextMessageAsync(identifier, "Введите дату в формате ДД.ММ");
                }
                else
                {
                    await((ITelegramBotClient)BotService.Client).SendTextMessageAsync(identifier, "Не больно то и хотелось");
                    chatRepository.ResetState(identifier);
                }
                break;
            }

            case writeDate:
            {
                var current = createEventRepository.GetCurrentEventCreatorModel(identifier);
                if (current != null)
                {
                    current.Date = m.Text;
                    //createEventRepository.SetEventCreatorModel(identifier, current);
                    await((ITelegramBotClient)BotService.Client).SendTextMessageAsync(identifier, "Введите время начала в формате ЧЧ:ММ");
                    chatRepository.SetState(identifier, this, timeFrom);
                }
                else
                {
                    chatRepository.ResetState(identifier);
                }
                break;
            }

            case timeFrom:
            {
                var current = createEventRepository.GetCurrentEventCreatorModel(identifier);
                if (current != null)
                {
                    current.TimeFrom = m.Text;
                    //createEventRepository.SetEventCreatorModel(identifier, current);
                    await((ITelegramBotClient)BotService.Client).SendTextMessageAsync(identifier, "Введите время окончания в формате ЧЧ:ММ");
                    chatRepository.SetState(identifier, this, timeTo);
                }
                else
                {
                    chatRepository.ResetState(identifier);
                }
                break;
            }

            case timeTo:
            {
                var current = createEventRepository.GetCurrentEventCreatorModel(identifier);
                if (current != null)
                {
                    current.TimeTo = m.Text;
                    //createEventRepository.SetEventCreatorModel(identifier, current);
                    await((ITelegramBotClient)BotService.Client).SendTextMessageAsync(identifier, "Введите тему события");
                    chatRepository.SetState(identifier, this, subject);
                }
                else
                {
                    chatRepository.ResetState(identifier);
                }
                break;
            }

            case subject:
            {
                var current = createEventRepository.GetCurrentEventCreatorModel(identifier);
                if (current != null)
                {
                    current.Subject = m.Text;

                    var result = await botWebApiService.EventCreate(current);

                    if (result)
                    {
                        await((ITelegramBotClient)BotService.Client).SendTextMessageAsync(identifier, "Событие успешно создано!");
                    }
                    else
                    {
                        await((ITelegramBotClient)BotService.Client).SendTextMessageAsync(identifier, "Событие не создано :(");
                    }
                }
                chatRepository.ResetState(identifier);
                break;
            }

            default:
            {
                chatRepository.ResetState(identifier);
                break;
            }
            }
        }
Пример #2
0
 public Task <bool> EventCreate(EventCreatorModel model)
 {
     return(restClient.Execute <bool>("/PublicAPI/REST/EleWise.ELMA.ELMAHelperBot/Bot/EventCreate", model, RestSharp.Method.POST));
 }
Пример #3
0
 public void SetEventCreatorModel(long chatId, EventCreatorModel eventCreatorBody)
 {
     repo[chatId] = eventCreatorBody;
 }