I am trying to implement something like State Machine with MVC Controller. The client sends json messages to the action Play of the controller. Each message has a MessageCode and some other additional data, which depends on the MessageCode.
Exampple:
{MessageCode:1, words:["aaa","bbb","ccc"]}
{MessageCode:2, ClientsAge: 56, ClientsName:"Jon"}
...
Thus, I have
public JsonResult Play(int MessageCode)
{
switch(MessageCode){
case 1:
//Perform some additional checks
return _DoSomething1(words);
case 2:
//Perform some additional checks
return _DoSomething2(ClientsAge,ClientsName);
//
}
And each of the private methods _DoSomething1,_DoSomething2 etc. have different signatures.