Exemplo n.º 1
0
        public async Task <bool> AddProduct(Product product)
        {
            await _context.AddAsync <Product>(product);

            await _context.SaveChangesAsync();

            ProductElasticIndexDto productElasticIndexDto = new ProductElasticIndexDto();

            productElasticIndexDto.Adapt(product);
            await CreateIndexes(productElasticIndexDto);

            return(await Task.FromResult <bool>(true));
        }
Exemplo n.º 2
0
        public async Task <bool> ProductAddOrUpdateElasticIndexAsync(ProductElasticIndexDto productElasticIndexDto)
        {
            try
            {
                await _elasticSearchService.CreateProductIndexAsync <ProductElasticIndexDto, int>(ElasticSearchItemsConst.ProductIndexName);

                await _elasticSearchService.AddOrUpdateAsync <ProductElasticIndexDto, int>(ElasticSearchItemsConst.ProductIndexName, productElasticIndexDto);

                return(await Task.FromResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(await Task.FromException <bool>(ex));
            }
        }
Exemplo n.º 3
0
 private async void PostAddOrUpdateElasticIndexAsync(ProductElasticIndexDto productDto)
 {
     await _productService.ProductAddOrUpdateElasticIndexAsync(productDto);
 }