Skip to content

Instantly share code, notes, and snippets.

@warthurton
Last active December 27, 2015 10:09
Show Gist options
  • Save warthurton/7309089 to your computer and use it in GitHub Desktop.
Save warthurton/7309089 to your computer and use it in GitHub Desktop.
LightSwitch HTML Commanding with TheLightSwitchToolbox.WebApiCommanding.Server
/// <reference path="../GeneratedArtifacts/viewModel.js" />
myapp.BrowsePerson.PeopleCommanding_ItemTap_execute = function (screen) {
$.post("../api/Command/FirstCommand",
{ Parameter1: screen.People.selectedItem.Id, Parameter2: screen.People.selectedItem.FirstName },
function (data) {
if (data != null) {
screen.CommandReturn = data.Parameter2.toString();
return true;
}
screen.CommandReturn = "Error calling WebAPI";
return false;
});
};
public HttpResponseMessage FirstCommand(CommandParameters commandParameters)
{
var responseParameters = commandParameters;
responseParameters.Parameter2 =
"I did my job " + commandParameters.Parameter2
+ " ID: " + commandParameters.Parameter1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment