Skip to content

Instantly share code, notes, and snippets.

@davecra
Created July 3, 2017 14:47
Show Gist options
  • Save davecra/04df2b3a841bbc8014ba9573b448d613 to your computer and use it in GitHub Desktop.
Save davecra/04df2b3a841bbc8014ba9573b448d613 to your computer and use it in GitHub Desktop.
Web Service Controller for an OfficeJS Add-in
/// <summary>
/// CORE SERVICE FUNCTION
/// This function will take a web request which will contain the command the caller wants
/// to initate and then the paramaters needed for that call. We enter a SELECT statement
/// below to determine the command given and we then call the proper helper function
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost()]
public WebServiceResponse WebService(WebServiceRequest request)
{
WebServiceResponse response = null;
switch(request.Command)
{
case "DoFunctionA":
return functionA(request.Params);
case "DoFunctionB":
return functionB(request.Params);
case "DoFunctionC":
return functionC(request.Params);
case "DoFunctionD":
return functionD(request.Params);
}
response = new WebServiceResponse();
response.Message = "Unknown command";
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment