public async Task ApplyUserCultureAsync_UserExists_UserCultureApplied() { SetDefaultCulture(fixture.EnglishLanguage); SetupFind(mockUserService, userFixture.UserWithLanguageCode); await service.ApplyUserCultureAsync(userFixture.UserId); VerifyApplyCulture(mockUserService, userFixture.UserWithLanguageCode.LanguageCode); }
public override async Task Handle(TelegramBotClient client, CallbackQuery callbackQuery) { var chatId = callbackQuery.Message.Chat.Id; var userTelegramId = callbackQuery.From.Id; try { await client.DeleteMessageAsync(chatId, callbackQuery.Message.MessageId); await client.SendChatActionAsync(chatId, ChatAction.Typing); var successfully = await service.AddUserLanguageAsync(userTelegramId, callbackQuery.Data); if (successfully) { await service.ApplyUserCultureAsync(userTelegramId); await client.SendTextMessageAsync(chatId, CommandsResources.LanguageChanged, replyMarkup : new ReplyKeyboardRemove()); } } catch (ApiRequestException) { // language is already changed } }
public async Task <IHttpActionResult> Update([FromBody] Update update) { try { await service.ApplyUserCultureAsync(GetUserId(update)); switch (update.Type) { case UpdateType.Message: await HadleMessageAsync(update.Message, client); break; case UpdateType.CallbackQuery: await HandleCallbackQueryAsync(update, client); break; } } catch (Exception e) { LogManager.GetLogger(AppSettings.LoggerName).Error(e.Message, e); } return(Ok()); }