Exemplo n.º 1
0
        private void CallBack(System.Object sender, Telegram.Bot.Args.CallbackQueryEventArgs e)
        {
            if (commands.Any(c => c.Equals(e.CallbackQuery.Data)))                               // проверка есть ли команда в списке
            {
                ICommand Command = commands.FirstOrDefault(c => c.Equals(e.CallbackQuery.Data)); // вытягиваем класс
                Command.Execute(BotClient, e.CallbackQuery, pairs, baseContext);
            }
            else if (calendars.Any(c => c.Equals(e.CallbackQuery.Data)))
            {
                if (!keyValues.Any(c => c.Key == e.CallbackQuery.From.Id) || keyValues.Count == 0)
                {
                    keyValues.Add(e.CallbackQuery.From.Id, new Calendar());
                }

                ICalendar Command = calendars.FirstOrDefault(c => c.Equals(e.CallbackQuery.Data));                 // вытягиваем класс
                if (Command.Name == "BackToStart" || Command.Name == "BackToCalendar" ||
                    Command.Name == "Calendar" || Command.Name == "<" ||
                    Command.Name == ">")
                {
                    Command.Execute(BotClient, e.CallbackQuery, keyValues, baseContext);
                }
                else
                {
                    Command.Execute(BotClient, e.CallbackQuery, eventCals, baseContext);
                }
            }
            else if (commandSettings.Any(c => c.Equals(e.CallbackQuery.Data)))
            {
                ICommandSettings ISettings = commandSettings.FirstOrDefault(c => c.Equals(e.CallbackQuery.Data));
                ISettings.Execute(BotClient, e.CallbackQuery, iSettings, baseContext);
            }
            else if (commandiOrganizer.Any(c => c.Equals(e.CallbackQuery.Data)))
            {
                IOrganizer iTOrganizer = commandiOrganizer.FirstOrDefault(c => c.Equals(e.CallbackQuery.Data));
                iTOrganizer.Execute(BotClient, e.CallbackQuery, iOrganizer, baseContext);
            }
            else
            {
                User users = baseContext._User.Where(p => p.ID == e.CallbackQuery.From.Id).FirstOrDefault();
                if (users.Work / 100 <= 22)
                {
                    ChouseItem chouseItem = new ChouseItem();
                    chouseItem.Execute(BotClient, e.CallbackQuery, pairs, baseContext);
                }
                else if (users.Work / 100 == 30)
                {
                    ChouseData chouseData = new ChouseData();
                    chouseData.Execute(BotClient, e.CallbackQuery, baseContext);
                }
                else if (users.Work % 100 >= 26 && users.Work % 100 <= 28)
                {
                    ShowItemCalndar showItemCalnder = new ShowItemCalndar();
                    showItemCalnder.Execute(BotClient, e.CallbackQuery, eventCals, baseContext);
                }
            }
        }