-
Notifications
You must be signed in to change notification settings - Fork 13
/
GetCharacterInfoOrchestrator.cs
46 lines (40 loc) · 1.71 KB
/
GetCharacterInfoOrchestrator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Linq;
using System.Threading.Tasks;
using DurableFunctions.Demo.DotNetCore.Chaining.Activities;
using DurableFunctions.Demo.DotNetCore.Chaining.Activities.Models;
using DurableFunctions.Demo.DotNetCore.Chaining.Orchestrators.Models;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Microsoft.Extensions.Logging;
// ReSharper disable once CheckNamespace
namespace DurableFunctions.Demo.DotNetCore.Chaining.Orchestrators
{
public class GetCharacterInfoOrchestrator
{
[FunctionName(nameof(GetCharacterInfoOrchestrator))]
public async Task<CharacterInfo> Run(
[OrchestrationTrigger]IDurableOrchestrationContext context,
ILogger log)
{
var name = context.GetInput<string>();
var result = new CharacterInfo();
var characterResult = await context.CallActivityAsync<Character>(
nameof(SearchCharacterActivity),
name);
result.Name = characterResult.Name;
var homeWorldResult = await context.CallActivityAsync<string>(
nameof(GetPlanetActivity),
characterResult.PlanetUrl);
result.HomeWorld = homeWorldResult;
var speciesResult = await context.CallActivityAsync<Species>(
nameof(GetSpeciesActivity),
characterResult.SpeciesUrl.FirstOrDefault());
result.Species = speciesResult.Name;
var speciesHomeWorldResult = await context.CallActivityAsync<string>(
nameof(GetPlanetActivity),
speciesResult.HomeWorld);
result.SpeciesHomeWorld = speciesHomeWorldResult;
return result;
}
}
}