forked from ejadib/ParentChildFormBotFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Forms.cs
43 lines (39 loc) · 1.55 KB
/
Forms.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
namespace ParentChildForm
{
using System.Threading.Tasks;
using Microsoft.Bot.Builder.FormFlow;
using Microsoft.Bot.Builder.FormFlow.Advanced;
public class Forms
{
public static IForm<FlightFormState> BuildFlightForm()
{
return new FormBuilder<FlightFormState>()
.Field(nameof(FlightFormState.Flight))
.Build();
}
internal static IForm<PassengerFormState> BuildPassengersForm()
{
return new FormBuilder<PassengerFormState>()
.Field(new FieldReflector<PassengerFormState>(nameof(PassengerFormState.PassengerName))
.SetType(null)
.SetPrompt(PerLinePromptAttribute("Please select the passenger you want to check-in: {||}"))
.SetDefine((state, field) =>
{
foreach (var passenger in state.AvailablePassengers)
{
field
.AddDescription(passenger.FullName, passenger.FullName)
.AddTerms(passenger.FullName, passenger.FullName);
}
return Task.FromResult(true);
})).Build();
}
private static PromptAttribute PerLinePromptAttribute(string pattern)
{
return new PromptAttribute(pattern)
{
ChoiceStyle = ChoiceStyleOptions.PerLine
};
}
}
}