public async Task <ProductsResult> GetProducts(string searchString) { ProductsResult result = new ProductsResult(); try { GetProductsResult output = (GetProductsResult)_objectCache.GetItem(_productCacheKey); if (output == null) { throw new Exception("Products not found in cache. Reload the cache or reset it through the admin panel"); } if (output.ResultCode == -1) { throw new Exception(); } result.Products = output.Products?.Select(p => new Classes.Products { ProductGuid = p.ProductGuid, Name = p.Name }).ToList() ?? new List <Classes.Products>(); result.Products = result.Products.Where(p => p.Name.IndexOf(searchString) != -1).ToList(); } catch (Exception ex) { SetException(result, ex); } return(result); }
public async Task <ProductsResult> WarehouseProducts(ProductsRequest request) { ProductsResult result = new ProductsResult(); result.Products = await GetWarehouseProducts(request.WarehouseID); if (result.Products == null) { result.Products = new List <Models.Product>(); } return(result); }
private static ProductVm MapLineResultAndProductResultToProductVm(ProductsResult productsResult, LineResult line) { var matchProduct = productsResult?.Content? .FirstOrDefault(_ => string.Equals(_.MerchantProductNo, line.MerchantProductNo)) ?? throw new ApplicationException( $"Missing information about product {line.MerchantProductNo}"); return(new ProductVm { Quantity = line.Quantity, MerchantProductNo = line.MerchantProductNo, Name = matchProduct.Name, Ean = matchProduct.Ean }); }
public async Task <ProductsResult> GetProducts() { ProductsResult result = new ProductsResult(); try { GetProductsResult output = await _eatClient.GetProductsAsync(); if (output.ResultCode == -1) { throw new Exception(); } result.Products = output.Products?.Select(p => new Classes.Products { ProductGuid = p.ProductGuid, Name = p.Name }).ToList() ?? new List <Classes.Products>(); } catch (Exception ex) { SetException(result, ex); } return(result); }
public static void ShouldNotHavePreviousPage(this ProductsResult pr) => pr.Pagination.PreviousPage.Should().BeNull();
public static void ShouldHaveNextPage(this ProductsResult pr) => pr.Pagination.NextPage.Should().NotBeNull();