public IActionResult ModelBinding(Thing thing) { var model = new HomeModelBindingViewModel() { Thing = thing, HasErrors = !ModelState.IsValid, ValidationErrors = ModelState.Values.SelectMany(state => state.Errors).Select(error => error.ErrorMessage) }; return(View(model)); }
public IActionResult ModelBinding(Thing thing) { // return View(thing); // show the model bound thing var model = new HomeModelBindingViewModel { Thing = thing, HasErrors = !ModelState.IsValid, ValidationErrors = ModelState.Values .SelectMany(state => state.Errors) .Select(err => err.ErrorMessage) }; return(View(model)); }