C
C#2y ago
bookuha

❔ Entity logic splitting

Imagine you have two entites User and Group and two services : userService, GroupService In which one of there would you put a method "GetUsersByGroupId" Also, is it better to group controllers by what they return? Like, having endpoints for different resource in the same controller:
2 Replies
cumslvt13
cumslvt132y ago
That's a pure preference. You can do it multiple ways, like adding a filter by group id in /users endpoint or making a separate endpoint. That depends on what you actually try to achieve. Personally I group try to group controllers around entity. That doesn't actually mean that my controllers can return only one resource type. I definitely wouldn't mix groups and users in the same controller. However, such cases as /users/{id}/groups is pretty valid - since we're getting groups user belongs to
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.