public override async Task<GetMeaningForContextRequest> HandleAsync(GetMeaningForContextRequest command, CancellationToken cancellationToken = new CancellationToken()) { var query = new GetMeaningByContextQuery { DictionaryId = command.DictionaryId, WordId = command.WordId, Context = command.Context }; var result = await _queryProcessor.ExecuteAsync(query, cancellationToken); command.Result = result.Select(x => _meaningRenderer.Render(x, command.DictionaryId)); return await base.HandleAsync(command, cancellationToken); }
public override async Task <IEnumerable <MeaningModel> > ExecuteAsync(GetMeaningByContextQuery query, CancellationToken cancellationToken = new CancellationToken()) { using (var database = _databaseProvider.GetDatabaseForDictionary(query.DictionaryId)) { var meanings = await database.Meaning .Where(t => t.WordId == query.WordId && t.Context == query.Context) .ToListAsync(cancellationToken); return(meanings.Select(m => m.Map <Meaning, MeaningModel>())); } }
public override async Task <IEnumerable <MeaningModel> > ExecuteAsync(GetMeaningByContextQuery query, CancellationToken cancellationToken = new CancellationToken()) { return(await _apiClient.Get <IEnumerable <MeaningModel> >($"api/dictionaries/{query.DictionaryId}/words/{query.WordId}/meanings/contexts/{query.Context}")); }