public async Task <Product> BuildAsync() { var headers = await _defaultRequestHeadersService.GetAsync(); if (_product.StatusId.IsEmpty()) { throw new InvalidOperationException(nameof(_product.StatusId)); } var id = await _productsClient.CreateAsync(_product, headers); return(await _productsClient.GetAsync(id, headers)); }
public async Task <IActionResult> Index(string name) { var model = new ProductViewModel().ProductDtos; if (string.IsNullOrWhiteSpace(name)) { model = await _products.GetAsync(); } else { model = await _products.GetByNameAsync(name); } return(View(model)); }
public async Task WhenGet_ThenSuccess() { var headers = await _defaultRequestHeadersService.GetAsync(); var status = await _create.ProductStatus.BuildAsync(); var productId = ( await _create.Product .WithStatusId(status.Id) .BuildAsync()) .Id; var product = await _productsClient.GetAsync(productId, headers); Assert.NotNull(product); Assert.Equal(productId, product.Id); }