public async Task <IReadOnlyCollection <Meeting> > Handle(SearchMeetings query, CancellationToken cancellationToken)
    {
        var response = await elasticClient.SearchAsync <Meeting>(
            s => s.Index(IndexNameMapper.ToIndexName <Meeting>())
            .Query(q => q.QueryString(d => d.Query(query.Filter))).Size(MaxItemsCount), cancellationToken);

        return(response.Documents);
    }
    public async Task Handle(TEvent @event, CancellationToken ct)
    {
        string id = getId(@event);

        var entity = (await elasticClient.GetAsync <TView>(id, ct: ct))?.Source
                     ?? (TView)Activator.CreateInstance(typeof(TView), true) !;

        entity.When(@event);

        var result = await elasticClient.UpdateAsync <TView>(id,
                                                             u => u.Doc(entity).Upsert(entity).Index(IndexNameMapper.ToIndexName <TView>()),
                                                             ct
                                                             );
    }
Exemplo n.º 3
0
 public Task Update(T aggregate, CancellationToken cancellationToken)
 {
     return(elasticClient.UpdateAsync <T>(aggregate.Id, i => i.Doc(aggregate).Index(IndexNameMapper.ToIndexName <T>()), cancellationToken));
 }
Exemplo n.º 4
0
 public Task Add(T aggregate, CancellationToken cancellationToken)
 {
     return(elasticClient.IndexAsync(aggregate, i => i.Id(aggregate.Id).Index(IndexNameMapper.ToIndexName <T>()), cancellationToken));
 }