public static Task <List <ReadModels.PublicClassifiedAdListItem> > Query(this IAsyncDocumentSession session, GetPublishedClassifiedAds query) => session.Query <Domain.ClassifiedAd.ClassifiedAd>() .Where(x => x.State == Domain.ClassifiedAd.ClassifiedAd.ClassifiedAdState.Active) .Select(x => new ReadModels.PublicClassifiedAdListItem { Id = x.Id.Value.ToString(), Price = x.Price.Amount, Title = x.Title.Value, CurrencyCode = x.Price.Currency.CurrencyCode }).PagedList(query.Page, query.PageSize);
public static Task <List <PublicClassifiedAdListItem> > Query( this IAsyncDocumentSession session, GetPublishedClassifiedAds query) { return(session.Query <Domain.ClassifiedAd.ClassifiedAd>() .Where(x => x.State == ClassifiedAdState.Active) .Select(x => new PublicClassifiedAdListItem { ClassifiedAdId = x.Id.Value, Price = x.Price.Amount, Title = x.Title.Value, CurrencyCode = x.Price.Currency.CurrencyCode }) .PagedList(query.Page, query.PageSize)); }
public async Task <IEnumerable <ClassifiedAdListItemViewModel> > Query(GetPublishedClassifiedAds query) { using (var connection = new SqlConnection(_connectionString)) { connection.Open(); var result = await connection.QueryAsync <ClassifiedAdListItemViewModel>( @"select ClassifiedAdId as id, Title as title, Amount as price, CurrencyCode from ClassifiedAds c where c.state=@state" , new { state = (int)ClassifiedAdState.Active } ); if (result.AsList().Count == 0) { throw new KeyNotFoundException(); } // return MapClassifiedAdListItem(result); return(result); }; }
public static Task <IEnumerable <PublicClassifiedAdListItem> > Query(this DbConnection connection, GetPublishedClassifiedAds query) { return(connection.QueryAsync <PublicClassifiedAdListItem>( "SELECT \"ClassifiedAdId\", \"Price_Amount\", \"Title_Value\" " + "FROM \"ClassifiedAds\" WHERE \"State\"=@State LIMIT @PageSize OFFSET @Offset", new { State = (int)ClassifiedAdState.Active, PageSize = query.PageSize, Offset = Offset(query.Page, query.PageSize) })); }
public async Task <IEnumerable <ClassifiedAdListItemViewModel> > Get( [FromQuery] GetPublishedClassifiedAds request) => await _queries.Query(request);
public static Task <List <ClassifiedAdListItem> > Query(this IEnumerable <ClassifiedAdDetails> items, GetPublishedClassifiedAds query) => Task.FromResult(new List <ClassifiedAdListItem>());