August 2018
Intermediate to advanced
298 pages
5h 33m
English
The model state is automatically updated based on the Data Annotation attribute specified on our ViewModel and the input data. We are verifying whether the model state is valid in the following Index method, which is a POST action method. If the model state is valid (when the validation succeeds), we save the entered data to the database. If the validation fails, then the ModelState is set to invalid automatically. Then, we would populate ViewModel with the entered data and render the View method again so that the user can correct the input data and re-submit the data:
[HttpPost]public IActionResult Index(EmployeeAddViewModel employeeAddViewModel) ...
Read now
Unlock full access