Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

I think, to me, the Person controller needs to handle this.

A Person needs to know about a Phone - but a Phone needs no knowledge of a Person.

So your phone controller shouldn't need to know about Person at all.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900