So this should be a pretty easy one. In fact I've read lots of Q&A's on much more complicated Restful Design problems out there and I did not find the answer to this simple one... So if I have the following entity:
public class Guest
{
public int GuestId { get; set; }
public int PersonId { get; set; }
// bunch of other properties
}
What should my GuestController
look like if I want to have methods available to retrieve a Guest
object via the GuestId
or the PersonId
?
I know I could accomplish this by it looking something like this..
public class GuestsController
{
// GET api/guests/1
public Guest Get(int id)
{
// get the Guest by GuestId
}
// GET api/guests/GetbyPersonId/2
public Guest GetbyPersonId(int personId)
{
// get the Guest by PersonId
}
}
... and then using attribute routing or actions or whatever to reach the GetByPersonId
method, but that just doesn't seem to comply with the whole Restful design principles I've been reading about. What is suggested in this case?