[HttpPost]
public async Task<ContentResult> Perform(string operation, string entity, FormCollection form = null)
{
var json = string.Empty;
var returnTuple = new Tuple<string, int, string>(string.Empty, (int)HttpStatusCode.InternalServerError, "Default return value");
switch (operation)
{
case "GET":
switch (entity)
{
case ("ALLSCHOOLS"):
returnTuple = await GetSchools(form);
break;
...
}
break;
case "POST":
switch (entity)
{
case "SCHOOL":
returnTuple = await SaveSchool(form);
break;
...
}
break;
}
...
if (!string.IsNullOrEmpty(returnTuple.Item1))
{
json = returnTuple.Item1;
Response.StatusCode = (int)HttpStatusCode.OK;
}
else
{
Response.StatusCode = returnTuple.Item2;
Response.StatusDescription = returnTuple.Item3;
}
return Content(json, "application/json");
}