stop
This commit is contained in:
9
Batter.cs
Normal file
9
Batter.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace azure_functions_talk
|
||||
{
|
||||
public class Batter
|
||||
{
|
||||
public string Id { get; set; }
|
||||
}
|
||||
}
|
||||
7
CompleteDounut.cs
Normal file
7
CompleteDounut.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace azure_functions_talk
|
||||
{
|
||||
public class CompleteDounut : Fried
|
||||
{
|
||||
public string Topping { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -12,13 +12,8 @@ namespace azure_functions_talk
|
||||
{
|
||||
public class Dounut
|
||||
{
|
||||
private static List<string> flavors = new List<string>()
|
||||
{
|
||||
"choco",
|
||||
"strawberry",
|
||||
"blackberry",
|
||||
"boston creme",
|
||||
"vanilla"
|
||||
private static List<string> flavors = new List<string>() {
|
||||
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()
|
||||
|
||||
@@ -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<Dounut>(a.Result))
|
||||
.Select(a => a.Flavor)
|
||||
.Select(a => a.Topping)
|
||||
.ToList();
|
||||
return new OkObjectResult("Your dounuts sir! " + String.Join(' ', dozen));
|
||||
}
|
||||
|
||||
10
Fried.cs
Normal file
10
Fried.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace azure_functions_talk
|
||||
{
|
||||
public class Fried : Batter
|
||||
{
|
||||
public bool Done = true;
|
||||
|
||||
}
|
||||
}
|
||||
24
Fryer.cs
Normal file
24
Fryer.cs
Normal file
@@ -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<IActionResult> Run(
|
||||
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] Batter req,
|
||||
ILogger log)
|
||||
{
|
||||
await Task.Delay(100);
|
||||
return new OkObjectResult(new Fried() { Id = req.Id });
|
||||
}
|
||||
}
|
||||
}
|
||||
23
GetBatter.cs
Normal file
23
GetBatter.cs
Normal file
@@ -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() } );
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Topper.cs
Normal file
35
Topper.cs
Normal file
@@ -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<Toppings> flavors = new List<Toppings>() {
|
||||
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<IActionResult> Run(
|
||||
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] Fried req,
|
||||
ILogger log)
|
||||
{
|
||||
await Task.Delay(50);
|
||||
return new OkObjectResult(new CompleteDounut() { Topping = GetTopping() });
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Toppings.cs
Normal file
11
Toppings.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace azure_functions_talk
|
||||
{
|
||||
public enum Toppings
|
||||
{
|
||||
choco,
|
||||
strawberry,
|
||||
blackberry,
|
||||
bostonCreme,
|
||||
vanilla
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user