public Task <IList <Product> > Handle(GetAllProductQuery request, CancellationToken cancellationToken) { var products = _productRepository.Get(); _mediator.Publish(new ProductGetNotification(products.Count), cancellationToken); return(Task.FromResult(products)); }
public async Task<IEnumerable<Product>> Handle(GetAllProductQuery request, CancellationToken cancellationToken) { string sql = $"SELECT * FROM Products "; using (var connection = new SqlConnection(configurationRoot.GetConnectionString("DbPocDatabase"))) { IEnumerable<Product> result = await connection.QueryAsync<Product>(sql); return result.ToList(); } }
public async Task <List <ProductDto> > Handle(GetAllProductQuery request, CancellationToken cancellationToken) { var response = await productRepository.GetListAsync(selector : ProductExpressions.ProductDtos); return(response.ToList()); }
public async Task <IReadOnlyList <ProductReadModel> > HandleAsync(GetAllProductQuery query, CancellationToken cancellationToken = new CancellationToken()) { return(await _repo.QueryListAsync(null, 0, 20, cancellationToken)); }
public async Task <Result <List <Product> > > Handle(GetAllProductQuery request, CancellationToken cancellationToken) { var products = await _dbContext.Set <Product>().ToListAsync(cancellationToken: cancellationToken); return(products); }
public async Task <List <ProductDto> > Handle(GetAllProductQuery request, CancellationToken cancellationToken) { var result = await _appContext.Products.Include(x => x.Category).ToListAsync(); return(_mapper.Map <List <ProductDto> >(result)); }
Task <IReadOnlyList <ProductModel> > IRequestHandler <GetAllProductQuery, IReadOnlyList <ProductModel> > .Handle(GetAllProductQuery request, CancellationToken cancellationToken) { try { return(mediator.Send <IReadOnlyList <ProductModel> >(new GetAllProductRepositoryQuery())); } catch { throw; } }
public async Task <ViewResult> Index(GetAllProductQuery query) { var result = await _mediator.Send(query); return(View(result)); }
async Task <IReadOnlyList <ProductResponseDTO> > IRequestHandler <GetAllProductQuery, IReadOnlyList <ProductResponseDTO> > .Handle(GetAllProductQuery request, CancellationToken cancellationToken) { var productCacheList = await distributedCache?.GetStringAsync("Product-List"); if (productCacheList != null) { var productList = JsonConvert.DeserializeObject <List <ProductResponseDTO> >(productCacheList); return(productList.AsReadOnly()); } return(null); }