예제 #1
0
        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());
        }
예제 #4
0
 public async Task <IReadOnlyList <ProductReadModel> > HandleAsync(GetAllProductQuery query, CancellationToken cancellationToken = new CancellationToken())
 {
     return(await _repo.QueryListAsync(null, 0, 20, cancellationToken));
 }
예제 #5
0
        public async Task <Result <List <Product> > > Handle(GetAllProductQuery request, CancellationToken cancellationToken)
        {
            var products = await _dbContext.Set <Product>().ToListAsync(cancellationToken: cancellationToken);

            return(products);
        }
예제 #6
0
        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));
        }
예제 #7
0
 Task <IReadOnlyList <ProductModel> > IRequestHandler <GetAllProductQuery, IReadOnlyList <ProductModel> > .Handle(GetAllProductQuery request, CancellationToken cancellationToken)
 {
     try
     {
         return(mediator.Send <IReadOnlyList <ProductModel> >(new GetAllProductRepositoryQuery()));
     }
     catch
     {
         throw;
     }
 }
예제 #8
0
        public async Task <ViewResult> Index(GetAllProductQuery query)
        {
            var result = await _mediator.Send(query);

            return(View(result));
        }
예제 #9
0
        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);
        }