Last active
July 9, 2018 06:14
-
-
Save pacodelacruz/0a68b4f12e060ac5c89dc46e5e455d39 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
using Microsoft.Azure.WebJobs; | |
using Microsoft.Extensions.Logging; | |
using PacodelaCruz.DurableFunctions.AsyncHttpApi.Models; | |
using System.Threading.Tasks; | |
namespace PacodelaCruz.DurableFunctions.AsyncHttpApi | |
{ | |
public static class ProcessSubmission | |
{ | |
/// <summary> | |
/// Durable Functions Orchestration | |
/// Receives a Call-for-Speaker submissions and control the approval workflow. | |
/// Updates the Orchestration Instance Custom Status as it progresses. | |
/// </summary> | |
/// <param name="context"></param> | |
/// <param name="logger"></param> | |
/// <returns></returns> | |
[FunctionName("ProcessSubmission")] | |
public static async Task<bool> RunOrchestrator( | |
[OrchestrationTrigger] DurableOrchestrationContext context, | |
ILogger logger) | |
{ | |
Presentation presentation = context.GetInput<Presentation>(); | |
presentation.Id = context.InstanceId; | |
string stage; | |
string status; | |
bool isTrackingEvent = true; | |
bool approved; | |
stage = "Moderation"; | |
// Set the custom status for the ochestration instance. | |
// This can be any serialisable object. In this case it is just a string. | |
context.SetCustomStatus(stage); | |
approved = await context.CallActivityAsync<bool>("Moderate", presentation); | |
if (approved) | |
{ | |
stage = "Shortlisting"; | |
context.SetCustomStatus(stage); | |
approved = await context.CallActivityAsync<bool>("Shortlist", presentation); | |
if (approved) | |
{ | |
stage = "Selection"; | |
context.SetCustomStatus(stage); | |
approved = await context.CallActivityAsync<bool>("Select", presentation); | |
} | |
} | |
if (approved) | |
status = "Approved"; | |
else | |
status = "Rejected"; | |
context.SetCustomStatus(status); | |
logger.LogInformation("Submission has been {status} at stage {stage}. {presenter}, {title}, {track}, {speakerCountry}, {isTrackingEvent}", status, stage, presentation.Speaker.Email, presentation.Title, presentation.Track, presentation.Speaker.Country, isTrackingEvent); | |
return approved; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment