Exemple #1
0
        public override async Task <GetTranslationsForWordRequest> HandleAsync(GetTranslationsForWordRequest command, CancellationToken cancellationToken = new CancellationToken())
        {
            var query = new GetTranslationsByWordIdQuery {
                DictionaryId = command.DictionaryId, WordId = command.WordId
            };
            var result = await _queryProcessor.ExecuteAsync(query, cancellationToken);

            command.Result = result.Select(t => _translationRenderer.Render(t, command.DictionaryId));

            return(await base.HandleAsync(command, cancellationToken));
        }
Exemple #2
0
        public override async Task <IEnumerable <TranslationModel> > ExecuteAsync(GetTranslationsByWordIdQuery query, CancellationToken cancellationToken = new CancellationToken())
        {
            using (var database = _databaseProvider.GetDatabaseForDictionary(query.DictionaryId))
            {
                var translations = await database.Translation
                                   .Where(t => t.WordId == query.WordId)
                                   .ToListAsync(cancellationToken);

                return(translations.Select(t => t.Map <Translation, TranslationModel>()));
            }
        }
 public override async Task <IEnumerable <TranslationModel> > ExecuteAsync(GetTranslationsByWordIdQuery query, CancellationToken cancellationToken = new CancellationToken())
 {
     return(await _apiClient.Get <IEnumerable <TranslationModel> >($"api/dictionaries/{query.DictionaryId}/words/{query.WordId}/translations"));
 }