Hi thank you for your good framework In ASPNETBoilerPlate with entityFramework , I want to validate User input for uniqueness in some fields by an specific criteria, i have to query from database and check uniqueness of input and return suitable message when duplicate data entered by the user, otherwise save data to database. where can i write my query and add validation error if duplicate data entered by the user? Is this a business rule and must be implemented in core (domain) project? Do you have any sample of this situation?
3 Answer(s)
-
0
I think it's a business rule. You can do it in database level (by creating a unique index) and also with checking by code in the Domain project. You may have a domain service, it checks the uniqueness and throws UserFriendlyException (if you want to show exception to the user).
-
0
Thank you. I read your the domain service documentation.I can throw an exception if duplicate data entered by the user, But i have a problem, If i have multiple business rules and i want to return multiple error string to the User in a single service call, how can i do it?
-
0
Hi,
Then it's your design. You can collect error messages, concat them and throws a single user friendly exception. no other way.. you can not throw 2 exception and expect ABP to collect and unify them which is impossible in C# :)