public override async Task ExecuteAsync(Message message, TelegramBotClient botClient) { var chatId = (int)message.Chat.Id; using (TelegramContext db = new TelegramContext()) { var User = db.Users.Where(p => p.Id == message.From.Id).SingleOrDefault(); if (User == null) { User user = new User { Id = chatId, Name = message.From.Username }; UserState us = new UserState { User = user, State = (int)UserStatesEnum.Empty, LastMessageId = message.MessageId }; db.Users.Add(user); db.UserStates.Add(us); db.SaveChanges(); UserLocker.AddUser(chatId); UserLocker.LockUser(chatId); } VacanciesManager.MainMenu(message, botClient); } }
public static async void ChoseCallBackQuery(Telegram.Bot.TelegramBotClient botClient, Update update) { try { using (TelegramContext db = new TelegramContext()) { var user = db.Users.Where(x => x.Id == update.CallbackQuery.From.Id).Single(); var callBack = update.CallbackQuery; await botClient.AnswerCallbackQueryAsync(update.CallbackQuery.Id); if (callBack.Data == "ShowPrice") { VacanciesManager.ShowPrice(botClient, update.CallbackQuery.Message); } else if (callBack.Data == "AddVacancy") { VacanciesManager.AddVacancу(botClient, update.CallbackQuery.Message, db); } else if (callBack.Data == "AddHeader") { AddHeaderCallback(botClient, update.CallbackQuery.Message); } else if (callBack.Data == "AddDescription") { AddDescriptionCallback(botClient, update.CallbackQuery.Message); } else if (callBack.Data == "AddResponsibilities") { AddResponsibilitiesCallback(botClient, update.CallbackQuery.Message, db); } else if (callBack.Data == "AddRequirements") { AddRequirementsCallback(botClient, update.CallbackQuery.Message, db); } else if (callBack.Data == "AddOffered") { AddOfferedCallback(botClient, update.CallbackQuery.Message, db); } else if (callBack.Data == "AddPaymentOffers") { AddPaymentOffersCallback(botClient, update.CallbackQuery.Message); } else if (callBack.Data == "AddAdditionalComment") { AddAdditionalCommentCallback(botClient, update.CallbackQuery.Message); } else if (callBack.Data == "AddContacts") { AddContactsCallback(botClient, update.CallbackQuery.Message, db); } else if (callBack.Data == "ConfirmVacancу") { VacanciesManager.ConfirmVacancу(botClient, update.CallbackQuery.Message, db); } else if (callBack.Data == "SaveVacancy") { VacanciesManager.SaveVacancу(botClient, update.CallbackQuery.Message, db); } else if (callBack.Data == "MainMenu") { VacanciesManager.MainMenu(update.CallbackQuery.Message, botClient); } } } catch (Exception ex) { Console.WriteLine(ex); } }