public async Task <IActionResult> Edit(ProductViewModel model) { if (ModelState.IsValid) { var modelResult = await _factory.ExceuteUpdate(model); model = modelResult.Model; if (modelResult.Errors.Count > 0) { AddErrors(modelResult.Errors); } return(View(model)); } return(View(model)); }
public async Task TestExecuteUpdateShouldReturnProductViewModelAndStringList() { ProductViewModel viewModel = new ProductViewModel { Name = "Test", NoOfUnit = 12, ReOrderLevel = 1, UnitPrice = 100, }; _mediator.Setup(m => m.Send(It.IsAny <UpdateProductCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new UpdateProductCommandResponse() { }); var result = await _factory.ExceuteUpdate(viewModel); Assert.That(result.GetType(), Is.EqualTo(typeof((ProductViewModel Model, List <string> Errors)))); }