I have Users collection with User's. User - Id, FName, LName.
For insert, I pass User instance with Id, FName, LName. The service inserts the User if it's not present.
For update, I again pass User instance with all parameters. The service updates FName and LName for the User with the given Id.
I want to have insert and update as 2 separate methods in the service.
I can't have same URI's for both methods. Something like below:
[WebInvoke(UriTemplate = "Users", Method = "PUT")]
void UpdateUser(User instance);
[WebInvoke(UriTemplate = "Users", Method = "PUT")]
void AddUser(User instance);
Which is the best way to acheive this?
I don't agree with one post saying update URI to have something like :
[WebInvoke(UriTemplate = "Users/{userId}", Method = "PUT")]
void UpdateUser(string userId, User instance);
Because, user id is already present in the Userinstance.
Though I agree that PUT method can perform insert and update. For some reason I need to keep them separate.