Exemplo n.º 1
0
        public SkillResponse Handle(IntentRequest intentRequest, ILambdaContext context, Session session)
        {
            var goApiClient = new GoApiClient();
            var intent      = intentRequest.Intent;

            if (IsDialogIntentRequest(intentRequest))
            {
                if (IsDialogSequenceComplete(intentRequest) == false)
                {
                    return(ResponseBuilder.DialogDelegate(session));
                }
            }

            var dateSlotValue = intent.Slots["date"].Value;
            var timeSlotValue = intent.Slots["time"].Value;
            var time          = Convert.ToDateTime(timeSlotValue);


            context.Logger.LogLine($"Date:{dateSlotValue}");

            var localBindDate   = NodaTime.AmazonDate.AmazonDateParser.Parse(dateSlotValue);
            var dateFrom        = localBindDate.From.ToDateTimeUnspecified();
            var bookingDateTime = new DateTime(dateFrom.Year, dateFrom.Month, dateFrom.Day, time.Hour, time.Minute, time.Second);

            var result = goApiClient.CancelBooking(new CancelBookingParams
            {
                ClassStartDate = bookingDateTime,
                ClassName      = "not used"
            }).Result;

            return(ResponseBuilder.Tell(result.Errors.Any() ? "There was an error canceling a booking. Please try again." : "Booking was canceled."));
        }
Exemplo n.º 2
0
        public async Task CancelBooking_Should_Return_Error_For_BadRequest()
        {
            var goApiClient = new GoApiClient();
            var result      = await goApiClient.CancelBooking(new CancelBookingParams
            {
                ClassName      = "aaa",
                ClassStartDate = DateTime.Now
            });

            Assert.NotNull(result);
            Assert.True(result.Errors.Any());
        }
Exemplo n.º 3
0
        public async Task CancelBooking_Should_Return_Success_For_ValidRequest()
        {
            var goApiClient     = new GoApiClient();
            var bookClassResult = await goApiClient.BookClass(new BookClassParams
            {
                ClassName      = "Aerobics",
                ClassStartDate = new DateTime(2018, 8, 31, 0, 0, 0)
            });

            Assert.NotNull(bookClassResult);
            Assert.False(bookClassResult.Errors.Any());

            var result = await goApiClient.CancelBooking(new CancelBookingParams
            {
                ClassName      = "Aerobics",
                ClassStartDate = new DateTime(2018, 8, 31, 0, 0, 0)
            });

            Assert.NotNull(result);
            Assert.False(result.Errors.Any());
        }