chatrli
❔ Relationship validation
Here is my controller, feel free to navigate through the repo: https://github.com/chatrli/api_onotebook/blob/emails/Controllers/PeopleController.cs
I added a relationship between my Person and Email models.
Then I wrote a POST method to add an new email to a person by its id but i always the same error using postman and curl (with this route http://localhost:5062/people/1/emails)
I don't need the person field to be required actually I want to be able to have Person with no email and just register new email later. There is no Person + Email creation the same time.
As I'm new to dotnet and have to be confortable with at least web api soon, I wish I can see how a simple relationship is used through the controller. Else if you have an explanation I will be glad.
What I tried so far is making the Person field nullable in the Post method for create email but in comparison of other backend Im working with so far, it feels like a non sense.
When I said it feels like a non sense I mean that this should not require to be nullable? We should be able to just add a new email without creating a new Person, as on client side, there is 2 form. One for the Person and a second one for the Email that is in Person Detail page.
32 replies