public async Task <IEnumerable <Product> > Handle(GetTopProducts getTopProducts) { var db = _container.Resolve <SampleContext>(); var products = await _repository.FindAll <Product>() .OrderByDescending(p => p.CreateTime) .Take(getTopProducts.Count) .ToListAsync() .ConfigureAwait(false); return(products); }
public async Task <ApiResult <IEnumerable <Product> > > GetTopProducts([FromUri] GetTopProducts getTopProducts) { return(await ProcessAsync(() => _productService.Handle(getTopProducts))); }