public R.Query <R.Paged <Responses.Index> > Handle(Services.Select query) { if (query.Id.HasValue) { var result = _client.Get <Responses.Index>(query.Id.Value); var paged = new R.Paged <Responses.Index> { Records = new[] { result.Source }, Total = 1 }; return(new R.Query <R.Paged <Responses.Index> > { Payload = paged }); } else { var results = _client.Search <Responses.Index>(s => s .Take(Int32.MaxValue) .Query(q => q.Term(f => f.Code, query.Term, Boost: 2) || q.Term(f => f.ParentCode, query.Term, Boost: 1) || q.Term(f => f.Name, query.Term, 5)) ); //.Query(q => q.QueryString(qs => qs.OnFieldsWithBoost(d => d.Add(e => e.ParentCode, 2).Add(e => e.Code, 1).Add(e => e.Name, 5)).WildQuery(request.Term)))); var paged = new R.Paged <Responses.Index> { Records = results.Documents, Total = results.Total, ElapsedMs = results.ElapsedMilliseconds }; return(new R.Query <R.Paged <Responses.Index> > { Payload = paged, Etag = Guid.Empty, SubscriptionId = query.SubscriptionId, SubscriptionTime = query.SubscriptionTime }); } }
public R.Query <R.Paged <Responses.Index> > Handle(Services.Index query) { var results = _client.Search <Responses.Index>(s => s.Paging(query)); var paged = new R.Paged <Responses.Index> { Records = results.Documents, Total = results.Total, ElapsedMs = results.ElapsedMilliseconds }; return(new R.Query <R.Paged <Responses.Index> > { Payload = paged, Etag = Guid.Empty, SubscriptionId = query.SubscriptionId, SubscriptionTime = query.SubscriptionTime }); }
public R.Query <R.Paged <Responses.Rate> > Handle(Services.GetRate query) { using (var session = _store.OpenSession()) { var rates = session.Query <Responses.Rate>().Where(x => x.CurrencyId == query.CurrencyId || x.DestinationCurrencyId == query.CurrencyId).OrderByDescending(x => x.EffectiveTill).Take(10).ToList(); var paged = new R.Paged <Responses.Rate> { Records = rates, Total = rates.Count() }; return(new R.Query <R.Paged <Responses.Rate> > { Payload = paged, Etag = Guid.Empty, SubscriptionId = query.SubscriptionId, SubscriptionTime = query.SubscriptionTime }); } }
public R.Query <R.Paged <Responses.Index> > Handle(Services.Index query) { var results = _client.Search <Responses.Index>(s => s.Paging(query)); var paged = new R.Paged <Responses.Index> { Records = results.Documents, Total = results.Total, ElapsedMs = results.ElapsedMilliseconds }; var response = new R.Query <R.Paged <Responses.Index> > { Payload = paged, Etag = Guid.Empty, SubscriptionId = query.SubscriptionId, SubscriptionTime = query.SubscriptionTime }; if (query.SubscriptionId.IsNullOrEmpty()) { return(response); } //_manager.AddTracked(response, Request.GetPermanentSessionId()); return(response); }