diff --git a/Batter.cs b/Batter.cs new file mode 100644 index 0000000..a9e07e4 --- /dev/null +++ b/Batter.cs @@ -0,0 +1,9 @@ +using System; + +namespace azure_functions_talk +{ + public class Batter + { + public string Id { get; set; } + } +} \ No newline at end of file diff --git a/CompleteDounut.cs b/CompleteDounut.cs new file mode 100644 index 0000000..e5f61bb --- /dev/null +++ b/CompleteDounut.cs @@ -0,0 +1,7 @@ +namespace azure_functions_talk +{ + public class CompleteDounut : Fried + { + public string Topping { get; set; } + } +} \ No newline at end of file diff --git a/Dounut.cs b/Dounut.cs index a68f9bf..2c812b1 100644 --- a/Dounut.cs +++ b/Dounut.cs @@ -12,13 +12,8 @@ namespace azure_functions_talk { public class Dounut { - private static List flavors = new List() - { - "choco", - "strawberry", - "blackberry", - "boston creme", - "vanilla" + private static List flavors = new List() { + Enum.GetName(typeof(Toppings), Toppings.blackberry), Enum.GetName(typeof(Toppings), Toppings.bostonCreme), Enum.GetName(typeof(Toppings), Toppings.choco), Enum.GetName(typeof(Toppings), Toppings.strawberry), Enum.GetName(typeof(Toppings), Toppings.vanilla) }; public string Flavor { get; set; } = RandomFlavor(); public static string RandomFlavor() diff --git a/DozenPlz.cs b/DozenPlz.cs index f6640c3..266268c 100644 --- a/DozenPlz.cs +++ b/DozenPlz.cs @@ -24,11 +24,11 @@ namespace azure_functions_talk var baseUrl = Environment.GetEnvironmentVariable("baseUrl"); try { - var tasks = Enumerable.Range(0, 12).Select(a => client.GetStringAsync(baseUrl + "/api/make")); - await Task.WhenAll(tasks); + var tasks = Enumerable.Range(0, 12).Select(a => { + return new CompleteDounut() { Id = Guid.NewGuid().ToString(), Topping = Topper.GetTopping() }; + }); var dozen = tasks - .Select(a => JsonConvert.DeserializeObject(a.Result)) - .Select(a => a.Flavor) + .Select(a => a.Topping) .ToList(); return new OkObjectResult("Your dounuts sir! " + String.Join(' ', dozen)); } diff --git a/Fried.cs b/Fried.cs new file mode 100644 index 0000000..e22c735 --- /dev/null +++ b/Fried.cs @@ -0,0 +1,10 @@ +using System; + +namespace azure_functions_talk +{ + public class Fried : Batter + { + public bool Done = true; + + } +} \ No newline at end of file diff --git a/Fryer.cs b/Fryer.cs new file mode 100644 index 0000000..b47f248 --- /dev/null +++ b/Fryer.cs @@ -0,0 +1,24 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.Http; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace azure_functions_talk +{ + public static class Fryer + { + [FunctionName("Fryer")] + public static async Task Run( + [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] Batter req, + ILogger log) + { + await Task.Delay(100); + return new OkObjectResult(new Fried() { Id = req.Id }); + } + } +} diff --git a/GetBatter.cs b/GetBatter.cs new file mode 100644 index 0000000..3f4c614 --- /dev/null +++ b/GetBatter.cs @@ -0,0 +1,23 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.Http; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace azure_functions_talk +{ + public static class GetBatter + { + [FunctionName("GetBatter")] + public static IActionResult Run( + [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "batter")] HttpRequest req, + ILogger log) + { + return new OkObjectResult( new Batter() { Id = Guid.NewGuid().ToString() } ); + } + } +} diff --git a/Topper.cs b/Topper.cs new file mode 100644 index 0000000..990f78e --- /dev/null +++ b/Topper.cs @@ -0,0 +1,35 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.Http; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace azure_functions_talk +{ + public static class Topper + { + private static List flavors = new List() { + Toppings.blackberry, + Toppings.bostonCreme, + Toppings.choco, + Toppings.strawberry, + Toppings.vanilla + }; + public static string GetTopping() { + return Enum.GetName(typeof(Toppings), flavors[new Random().Next(flavors.Count)]); + } + [FunctionName("Topper")] + public static async Task Run( + [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] Fried req, + ILogger log) + { + await Task.Delay(50); + return new OkObjectResult(new CompleteDounut() { Topping = GetTopping() }); + } + } +} diff --git a/Toppings.cs b/Toppings.cs new file mode 100644 index 0000000..8620b9d --- /dev/null +++ b/Toppings.cs @@ -0,0 +1,11 @@ +namespace azure_functions_talk +{ + public enum Toppings + { + choco, + strawberry, + blackberry, + bostonCreme, + vanilla + } +} \ No newline at end of file