public IQueryable<ProductVariant> Get(LowStockReportSearchModel searchModel) { IQueryable<ProductVariant> queryOver = _session.Query<ProductVariant>().Where(variant => variant.TrackingPolicy == TrackingPolicy.Track); if (_ecommerceSettings.WarehouseStockEnabled) { queryOver = queryOver.Where( variant => variant.WarehouseStock.Sum(stock => stock.StockLevel) <= searchModel.Threshold); } else { queryOver = queryOver.Where(variant => variant.StockRemaining <= searchModel.Threshold); } return queryOver.Cacheable(); }
public ExportStockReportResult ExportLowStockReport(LowStockReportSearchModel searchModel) { try { List<ProductVariant> items = _getLowStockQuery.Get(searchModel).ToList(); return new ExportStockReportResult { FileResult = GetLowStockFileResult(_getStockReportFile.GetFile(items)), Success = true }; } catch (Exception exception) { CurrentRequestData.ErrorSignal.Raise(exception); return new ExportStockReportResult { Message = _stringResourceProvider.GetValue("Export Low Stock Report Failed", "Low Stock Report exporting has failed. Please try again and contact system administration if error continues to appear.") }; } }
public IPagedList<ProductVariant> Search(LowStockReportSearchModel searchModel) { IQueryable<ProductVariant> queryOver = _getLowStockQuery.Get(searchModel); return queryOver.Paged(searchModel.Page); }