public void Api_UpdateProductInventory_ReturnsOkResult() { var testData = new ProductInventoryUpdateModel { ProductId = 1, Quantity = 2 }; /*Before Update*/ var data = _prdtRepo.GetData().FirstOrDefault(x => x.ProductId == 1); Assert.NotNull(data); Assert.Equal(1, data.ProductId); Assert.Equal(10, data.Quantity); /*Update Call*/ var result = _productController.UpdateProductInventory(testData); var dt = Assert.IsType <OkObjectResult>(result); Assert.Equal(true, dt.Value); /*After Update*/ data = _prdtRepo.GetData().FirstOrDefault(x => x.ProductId == 1); Assert.NotNull(data); Assert.Equal(1, data.ProductId); Assert.Equal(2, data.Quantity); }
public bool UpdateProductQuantity(ProductInventoryUpdateModel updateModel) { var data = _db.Product.Find(updateModel.ProductId); data.Quantity = updateModel.Quantity; _db.SaveChanges(); return(true); }
public async Task Ui_UpdateProductInventory_ReturnsOkResult() { var testData = new ProductInventoryUpdateModel { ProductId = 1, Quantity = 2 }; _productClient.Setup(x => x.UpdateProductQuantity(testData)).ReturnsAsync(true); var result = await _homeController.UpdateProductInventory(testData); Assert.IsType <OkResult>(result); }
public async Task <bool> UpdateProductQuantity(ProductInventoryUpdateModel updateModel) { var url = $"/api/Product/UpdateProductInventory"; var stringContent = new StringContent(JsonConvert.SerializeObject(updateModel), Encoding.UTF8, "application/json"); var response = _httpClient.PostAsync(url, stringContent).Result; response.EnsureSuccessStatusCode(); var responseString = await response.Content.ReadAsStringAsync(); var receivedData = JsonConvert.DeserializeObject <bool>(responseString, new JsonSerializerSettings()); return(receivedData); }
public async Task <IActionResult> UpdateProductInventory(ProductInventoryUpdateModel updateModel) { await _productClient.UpdateProductQuantity(updateModel); return(Ok()); }
public IActionResult UpdateProductInventory(ProductInventoryUpdateModel updateModel) { var data = _productRepo.UpdateProductQuantity(updateModel); return(Ok(data)); }