public IActionResult Search([FromBody] StockSearchFilter filter) { List <ProductModel> products = new List <ProductModel>(); try { IEnumerable <StockMovement> prodList = null; prodList = _productsRepo.GetProductsWithStock(filter.Name, filter.Description, filter.MinSellingPrice, filter.MaxSellingPrice, filter.MinStockBalance, filter.MaxStockBalance, filter.RecordsToReturn, filter.Tags); products = _mapper.Map <List <ProductModel> >(prodList); } catch (Exception ex) { _logger.LogError(ex, ex.Message); } return(PartialView("_ProductsStock", products)); }
public async Task <IEnumerable <StockItem> > Search(StockSearchFilter searchFilter) { var type = await new FileStockTypeRepository(this._memoryCacheService).Get("Aged Brie"); if (!this._memoryCacheService.TryGetValue <List <StockItem> >(FileStockRepository.cacheKey, out var stock)) { stock = new List <StockItem>(); var fileLocation = "../Data/Stock.txt"; using (var reader = new StreamReader(fileLocation)) { await this.SaveStock(reader); } this._memoryCacheService.TryGetValue <List <StockItem> >(FileStockRepository.cacheKey, out stock); } if (searchFilter?.StockType != null) { stock = stock.Where(item => item.StockTypeId == searchFilter.StockType).ToList(); } return(stock); }