Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Validating the entity already exist

$
0
0


I have an POST method to create an entity. In this table email is primary key and other columns are user information (name,surname, etc.)
I have two questions, please answer both :)
1) If customer send an email that already exist in database, API returns 500. But I want to return 400 and say "this email already in use". How can I do that when I trying to add new user to database.?
2) Is it true approach to make email as primary key for database design?

Im using ef core3.1 and asp.net core 3.1


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>