Created
September 26, 2016 09:20
-
-
Save AndyButland/00ce25771fe73acd94c246742c006e33 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 System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using Microsoft.Bot.Builder.FormFlow; | |
public class RoomBookingDialog | |
{ | |
public enum OfficeLocationOptions | |
{ | |
Bristol = 1, | |
London | |
} | |
public enum VideoConferenceOptions | |
{ | |
[Description("Best available")] | |
BestAvailable = 1, | |
[Description("Any available")] | |
AnyAvailable, | |
[Description("Telephone only")] | |
TelephoneOnly, | |
[Description("Not required")] | |
NotRequired | |
} | |
public enum HowLongOptions | |
{ | |
[Description("30 minutes")] | |
HalfAnHour = 1, | |
[Description("1 hour")] | |
AnHour, | |
[Description("90 minutes")] | |
NinetyMinutes, | |
[Description("2 hours")] | |
TwoHours, | |
[Description("3 hours")] | |
ThreeHours, | |
[Description("4 hours")] | |
FourHours, | |
[Description("All day")] | |
AllDay | |
} | |
public enum RefreshmentOptions | |
{ | |
[Description("Tea & coffee")] | |
TeaAndCoffee = 1, | |
Sandwiches | |
} | |
[Serializable] | |
public class RoomBookingRequest | |
{ | |
[Prompt("Where is your meeting? {||}")] | |
public OfficeLocationOptions? OfficeLocation; | |
[Prompt("What video conferencing do you need? {||}")] | |
public VideoConferenceOptions? VideoConference; | |
[Prompt("What is the date and time of your meeting?")] | |
public DateTime? Date; | |
[Prompt("How long do you need the room for? {||}")] | |
public HowLongOptions? HowLong; | |
[Optional] | |
public List<RefreshmentOptions> Refreshments; | |
[Prompt("How many are attending?")] | |
public int? HowMany; | |
[Prompt("Any other instructions?")] | |
public string Comments; | |
public static IForm<RoomBookingRequest> BuildForm() | |
{ | |
return new FormBuilder<RoomBookingRequest>() | |
.Message("Book a Zone meeting room...") | |
.Field(nameof(OfficeLocation)) | |
.Field(nameof(VideoConference)) | |
.Field(nameof(Date)) | |
.Field(nameof(HowLong)) | |
.Field(nameof(Refreshments)) | |
.Field(nameof(HowMany)) | |
.Field(nameof(Comments)) | |
.Confirm(async (state) => | |
{ | |
var message = "You are requesting a requesting a meeting room in {Location} on {Date} for {HowLong},"; | |
if (state.Refreshments.IsAndAny()) | |
{ | |
message += " with {Refreshments},"; | |
} | |
message += " to accommodate {HowMany} people. Please confirm that you would like to make this booking?"; | |
return new PromptAttribute(message); | |
}) | |
.Build(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment