I'm creating a .NET Core 3 API with Entity Framework. The data comes from an existing database.
Now I have the following situation:
/persons -- get all the persons /companies -- get all the companies /attributes -- get all the attributes /attributes/groups -- get all the attribute groups /attributes/types -- get all the attribute types /attributes/usage - get all the attribute usages
- Attributes can belong to one or more groups.
- Attributes can have a type: person or company.
- Attributes are assigned to a person or company listed in the usage endpoint.
In the "end of use" we have something like:
fk_attribute_id = 1 identifier_attribute = 3 type_id = "person"
This means that person 3 has attribute 1.
fk_attribute_id = 2 identifier_attribute = 2 type_id = "company"
This means that company 2 has attribute 2.
In my API I have several controllers / services to get this data based on EF. The customer could combine the data to get the desired result.
Now I think it's nice to have these endpoints:
/persons/3/attributes -- Get the attributes of person 3 /companies/2/attributes -- Get the attributes of company 2
But … that means I have to somehow call my own endpoints and combine the data? I can also call the DB using a stored procedure, although we want to avoid business logic in several places.
What would be the best course of action for this? Should we say: The API does not offer this, good luck client. Or … are there other options to provide this?