I have ApiController with Get action like this:
public IEnumerable<Note> Get(Guid userId, Guid tagId)
{
var userNotes = _repository.Get(x => x.UserId == userId);
var tagedNotes = _repository.Get(x => x.TagId == tagId);
return userNotes.Union(tagedNotes).Distinct();
}
I want that the following requests was directed to this action:
- http://{somedomain}/api/notes?userId={Guid}&tagId={Guid}
- http://{somedomain}/api/notes?userId={Guid}
- http://{somedomain}/api/notes?tagId={Guid}
Which way should I do this?
UPDATE: Be careful, the api controller should not have another GET method without parameters or you should to use action with one optional parameter.