Sal Maglione

Sal Maglione

  • NA
  • 9
  • 1.7k

ASP application Error/valid handling with Repository pattern

Oct 27 2015 1:50 PM
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