Exemplo n.º 1
0
        public async Task AddUserLanguageAsync_LanguageExists_LanguageAdded()
        {
            SetupSetLanguageCode(mockUserService);

            var result = await service.AddUserLanguageAsync(userFixture.UserId, fixture.UkraineLanguageName);

            VerifySetLanguageCode(mockUserService, fixture.UkraineLanguage, Times.Once());
            Assert.True(result);
        }
Exemplo n.º 2
0
        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
            }
        }