private async Task <Teachers> ConfirmTeacherPasswordAsync(string key) { if (await GoogleSpreadsheetController.ConnectToSheetsAsync() == true) { GoogleSpreadsheetController.TeacherInformation teacherInformation = new GoogleSpreadsheetController.TeacherInformation(); var datas = await teacherInformation.GetSheetDataAsync(). ContinueWith <IList <IList <object> > >(t => teacherInformation.GetTeacherInformation().Result); foreach (var data in datas) { if (data.Count == 4 && key == data[1].ToString()) { var teacher = new Teachers() { FullName = data[2].ToString(), Subjects = data[3].ToString() }; return(teacher); } } User.TypeUser = await ConfirmUserRoleAsync(key); if (User.TypeUser != null && User.TypeUser == TypeUser.Pupil.ToString()) // if pupil { User.State = RegistrationStateMachine.EnterName.ToString(); await BalDbController.ChangeUserStateAsync(User.State, User.ChatId) .ContinueWith(_ => BalDbController.AddPupilAsync(User.ChatId).Wait()) .ContinueWith(_ => BalDbController.UpdateUserDataAsync(User).Wait()); } } return(null); }
public override async Task <dynamic> Execute(Message message, TelegramBotClient client, UserInfo userInformation) { if (await GoogleSpreadsheetController.ConnectToSheetsAsync() == true) // connect to google spreadsheet { var keyboard = GenerateInlineKeyBoardAsync().Result; await client.SendTextMessageAsync(userInformation.ChatId, text : InlineKeyboardCommand, replyMarkup : keyboard); return(true); } await client.SendTextMessageAsync(userInformation.ChatId, text : "нажаль сталася технічна помилка. Спробуйте будь ласка пізніше. "); return(true); }