forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindHotelsAction_ChangeCheckin.cs
29 lines (25 loc) · 1.06 KB
/
FindHotelsAction_ChangeCheckin.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
namespace LuisActions.Samples
{
using System;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Microsoft.Cognitive.LUIS.ActionBinding;
[Serializable]
[LuisActionBinding("FindHotels-ChangeCheckin", FriendlyName = "Change the hotel checkin date", CanExecuteWithNoContext = false)]
public class FindHotelsAction_ChangeCheckin : BaseLuisContextualAction<FindHotelsAction>
{
[Required(ErrorMessage = "Please provide the new check-in date")]
[LuisActionBindingParam(BuiltinType = BuiltInDatetimeTypes.Date)]
public DateTime? Checkin { get; set; }
public override Task<object> FulfillAsync()
{
if (this.Context == null)
{
throw new InvalidOperationException("Action context not defined.");
}
// assign new check-in date to FindHotelsAction
this.Context.Checkin = this.Checkin;
return Task.FromResult((object)$"Hotel checkin date changed to {this.Checkin?.ToShortDateString()}");
}
}
}