0
Answer

ASP application Error/valid handling with Repository pattern

Sal Maglione

Sal Maglione

9y
376
1
The Action: Create New User
 
Controller - calls repository Create
 
in the Create method you edit if the user id is already in database. If it is you want to avoid an insert and returnthe error
 
ModelSate cannot be updated to signal the controller an error 
 
once the validation is moved from the controller what is the best pattern to use.
 
in the above scenario a new Repository can be implemented 'DoesUserExist' to return the user name in the event the user id already exist.
This is a simple edit - but what if the validation is complex? How would one implement a robust validation process using the repository pattern