public async Task <IActionResult> Edit(int id) { ApiResponse <ProductDetailsResponse> apiResponse = await _productApiClient.Get(id); var editModel = _mapper.Map <ProductEditModel>(apiResponse.Response.Product); return(View("Create", editModel)); }
public async Task WhenUpdatingExistingProduct_ThenReturnsOk() { CreateProduct createModel = ProductModels.GetCreateModel(); ApiResponse <ViewProduct> createResponse = await _productApiClient.Create(createModel); Assert.That(createResponse.HttpStatusCode, Is.EqualTo(HttpStatusCode.Created)); _productIdToDelete = createResponse.Response.Id; CreateProduct updateModel = ProductModels.GetCreateModel(); updateModel.Name = "UpdatedName"; updateModel.Code = "UpdatedCode"; ApiResponse <ViewProduct> updateResponse = await _productApiClient.Update(updateModel, createResponse.Response.Id); Assert.That(updateResponse.HttpStatusCode, Is.EqualTo(HttpStatusCode.OK)); ApiResponse <ProductDetailsResponse> getResponse = await _productApiClient.Get(createResponse.Response.Id); Assert.That(getResponse.Response.Product.Id, Is.EqualTo(createResponse.Response.Id)); Assert.That(getResponse.Response.Product.Name, Is.EqualTo(updateModel.Name)); Assert.That(getResponse.Response.Product.Code, Is.EqualTo(updateModel.Code)); }
public async Task WhenGetingSingleProduct_ThenProductIsReturned() { int productId = _createdProductId; var product = await _productApiClient.Get(productId); Assert.That(product.Response.Product, Is.Not.Null); Assert.That(product.Response.Product.Id, Is.EqualTo(productId)); Assert.That(product.Response.Product.Name, Is.EqualTo(productModel.Name)); Assert.That(product.Response.Product.Code, Is.EqualTo(productModel.Code)); Assert.That(product.Response.Product.Price, Is.EqualTo(productModel.Price)); }