Assume, I have the following entity set below.
Phone(PhoneId, PhoneNumber)
Person(PersonId, FirstName, LastName)
Company(CompanyId, CompanyName)
Broker(BrokerId, BrokerName)
PersonPhone(PhoneId, PersonId, PhoneType)
CompanyPhone(PhoneId, CompanyId, PhoneType)
BrokerPhone(PhoneId, BrokerId)
As entity name suggests,
1. Phone/Broker/Company maintains there domain data.
2. PersonPhone/CompanyPhone/BrokerPhone tables keeps a mapping of differenet entities and there phone numbers.
The system needs to allow user to create/update the aforementioned entities and as well add add/remove phone numbers for them.
Question:
What should be the structure of Web API for this kind of scenario.
My confusion is which controller should handle the call "add a phone to person".
Should it directed to PersonController because there may be some specific business logic when adding phone to Person and a path like /api/person/id/addphone makes sense from client's perspective.
Or the call should be directed to PhoneController.AddPhoneToPerson method in which case the path might be /api/phone/attachtoperson/phoneid
Which one makes more sense.