public InlineKeyboardForRegistration UserSelectedGroup(Telegram.Bot.Args.MessageEventArgs e) { UsersInfoForRegistration person = new UsersInfoForRegistration( chat_id: e.Message.Chat.Id.ToString(), group_name: e.Message.Text, first_name: e.Message.From.FirstName, last_name: e.Message.From.LastName, user_name: e.Message.From.Username); logger.Info($"In UserSelectedGroup with " + $"user data {e.Message.From.FirstName} {e.Message.From.LastName} {e.Message.From.Id} "); try { inlineKeyboardForRegistration = new InlineKeyboardForRegistration(MySQL.UserRegistrationOrUpdatingAndGettingNonRequiredLessons(person)); } catch (MySqlException ex) { logger.Error($"Error occured in Bot_UserSelectedGroupHanldler in StartingRegistration " + $"with persons data: {person}" + $"with exception data: {ex}"); return(null); } inlineKeyboardForRegistration.MessageID = Bot.botClient.SendTextMessageAsync( chatId: e.Message.Chat, text: "Please, choose you lessons and press READY button:", replyMarkup: inlineKeyboardForRegistration.Keyboard).Result.MessageId; Bot.botClient.SendTextMessageAsync( chatId: e.Message.Chat, text: "And press READY button", replyMarkup: new ReplyKeyboardMarkup { Keyboard = new KeyboardButton[][] { new KeyboardButton[] { new KeyboardButton { Text = "READY" } } }, ResizeKeyboard = true, OneTimeKeyboard = true }); logger.Info("InlineKeyboardForRegistration was sent to user."); return(inlineKeyboardForRegistration); }
public static string[] UserRegistrationOrUpdatingAndGettingNonRequiredLessons(UsersInfoForRegistration person) { List <string> text_for_buttons = new List <string>(); var con = new MySqlConnection(constr); var cmd = new MySqlCommand(); try { OpenAndConfigureConnection(ref con, ref cmd); logger.Info(" Successfully opened and configured Connection in UserRegistration"); BeginTransaction(cmd); logger.Info("Successfully began the transaction in UserRegistration"); if (CheckIfUserAlreadyRegistered(person, cmd)) { DeleteFromUsObjCommun(person, cmd); logger.Info("Successfully deleted from USObjCommn in UpdatingGroupAndGettingNonRequiredLessons"); UpdateUsersGroup(person, cmd); logger.Info("Successfully updated Users Group t in UpdatingGroupAndGettingNonRequiredLessons"); } else { InsertUserInfo(person, cmd); logger.Info("Successfully inserted users info in UserRegistration"); } InsertRequiredLessons(person, cmd); logger.Info("Successfully inserted required lessons info in UserRegistration"); text_for_buttons = SelectNonRequiredLessons(person, cmd); logger.Info("Successfully selected non required lessons info in UserRegistration"); EndSuccessfulTransaction(cmd); logger.Info("Transaction was successfully ended in UserRegistration"); } finally { con.Close(); cmd.Dispose(); } return(text_for_buttons.ToArray()); }