Created
April 6, 2016 19:29
-
-
Save guitarrapc/3fd91076d0a862fcb373760bd11729d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "Newtonsoft.Json" | |
using System; | |
using System.Net; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log) | |
{ | |
log.Verbose($"Webhook was triggered!"); | |
string jsonContent = await req.Content.ReadAsStringAsync(); | |
dynamic data = JsonConvert.DeserializeObject(jsonContent); | |
if (data.first == null || data.last == null) { | |
return req.CreateResponse(HttpStatusCode.BadRequest, new { | |
error = "Please pass first/last properties in the input object" | |
}); | |
} | |
var extensionMethodTest = Enumerable.Range(1, 11).Select(x => x * 10).ToArray().ToJoinedString(","); | |
return req.CreateResponse(HttpStatusCode.OK, new { | |
greeting = $"Hello {data.first} {data.last} and {extensionMethodTest}!" | |
}); | |
} | |
public static string ToJoinedString<T>(this IEnumerable<T> source, string separator = "") | |
{ | |
return string.Join(separator, source); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment