Skip to content

Instantly share code, notes, and snippets.

@ktabori
Last active December 21, 2015 05:39
Show Gist options
  • Save ktabori/6258112 to your computer and use it in GitHub Desktop.
Save ktabori/6258112 to your computer and use it in GitHub Desktop.
/base API SUM
$(document).ready(function(){
$("input[id$='getSum']").click(function(){
if ($("input[id$='number1']").val() != ''){
var number1 = $("input[id$='number1']").val();
}
else{
var number1 = 0;
}
if ($("input[id$='number2']").val() != ''){
var number2 = $("input[id$='number2']").val();
}
else{
var number2 = 0;
}
$.ajax({
type: "GET",
url: "http://jobtest1.teasolutions.dk.web01.teasolutions.dk/base/Get/Sum/"+number1+"/"+number2+ .aspx",
dataType: "xml",
success: function(xml) {
$(xml).find('value').each(function(){
var value = $(this).text();
alert(number1 + " + " + number2 + " = " + value);
});
}
});
});
});
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using umbraco.presentation.umbracobase;
namespace Base
{
[RestExtension("Get")]
public class BaseClass
{
[RestExtensionMethod]
public static int Sum(int number1, int number2)
{
int[] array = { number1, number2 };
int sum = array.Sum();
return sum;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment