public void ThenTheRegistrantAssignsTheseSeats(Table table)
        {
            using (var orderController = RegistrationHelper.GetOrderController(conferenceInfo.Slug))
            {
                PricedOrder pricedOrder = null;
                var         timeout     = DateTime.Now.Add(Constants.UI.WaitTimeout);
                while ((pricedOrder == null || !pricedOrder.AssignmentsId.HasValue) && DateTime.Now < timeout)
                {
                    pricedOrder = RegistrationHelper.GetModel <PricedOrder>(orderController.Display(draftOrder.OrderId));
                }

                Assert.NotNull(pricedOrder);
                Assert.True(pricedOrder.AssignmentsId.HasValue);

                var orderSeats =
                    RegistrationHelper.GetModel <OrderSeats>(orderController.AssignSeats(pricedOrder.AssignmentsId.Value));

                foreach (var row in table.Rows)
                {
                    var seat = orderSeats.Seats.FirstOrDefault(s => s.SeatName == row["seat type"]);
                    Assert.NotNull(seat);
                    seat.Attendee.FirstName = row["first name"];
                    seat.Attendee.LastName  = row["last name"];
                    seat.Attendee.Email     = row["email address"];
                }

                orderController.AssignSeats(pricedOrder.AssignmentsId.Value, orderSeats.Seats.ToList());
            }
        }
        public void GivenTheSelectedOrderItems(Table table)
        {
            conferenceInfo         = ScenarioContext.Current.Get <ConferenceInfo>();
            registrationController = RegistrationHelper.GetRegistrationController(conferenceInfo.Slug);

            orderViewModel = RegistrationHelper.GetModel <OrderViewModel>(registrationController.StartRegistration().Result);
            Assert.NotNull(orderViewModel);

            registration = new RegisterToConference {
                ConferenceId = conferenceInfo.Id, OrderId = orderViewModel.OrderId
            };

            foreach (var row in table.Rows)
            {
                var orderItemViewModel = orderViewModel.Items.FirstOrDefault(s => s.SeatType.Description == row["seat type"]);
                Assert.NotNull(orderItemViewModel);
                int qt;
                if (!row.ContainsKey("quantity") || !Int32.TryParse(row["quantity"], out qt))
                {
                    qt = orderItemViewModel.SeatType.Quantity;
                }
                registration.Seats.Add(new SeatQuantity(orderItemViewModel.SeatType.Id, qt));
            }

            // Store for sharing between steps implementations
            ScenarioContext.Current.Set(registration);
            ScenarioContext.Current.Set(registrationController.ConferenceAlias);
        }
        public void ThenTheOrderShouldBeCreatedWithTheFollowingOrderItems(Table table)
        {
            draftOrder = RegistrationHelper.GetModel <DraftOrder>(registrationController.ThankYou(registrationViewModel.Order.OrderId));
            Assert.NotNull(draftOrder);

            foreach (var row in table.Rows)
            {
                var orderItem = draftOrder.Lines.FirstOrDefault(
                    l => l.SeatType == conferenceInfo.Seats.First(s => s.Description == row["seat type"]).Id);

                Assert.NotNull(orderItem);
                Assert.Equal(Int32.Parse(row["quantity"]), orderItem.ReservedSeats);
            }

            // Wait for event processing
            Thread.Sleep(Constants.WaitTimeout);
        }
        public void GivenTheRegistrantProceedToMakeTheReservation()
        {
            //Assert.True(redirect != null, "Reservation not accepted. May be waitlisted.");

            // Perform external redirection
            var timeout = DateTime.Now.Add(Constants.UI.WaitTimeout);

            while (DateTime.Now < timeout && registrationViewModel == null)
            {
                var redirect = registrationController.StartRegistration(registration, orderViewModel.OrderVersion) as RedirectToRouteResult;
                if (redirect != null)
                {
                    //ReservationUnknown
                    var result = registrationController.SpecifyRegistrantAndPaymentDetails(
                        (Guid)redirect.RouteValues["orderId"], orderViewModel.OrderVersion).Result;

                    Assert.IsNotType <RedirectToRouteResult>(result);
                    registrationViewModel = RegistrationHelper.GetModel <RegistrationViewModel>(result);
                }
            }

            Assert.False(registrationViewModel == null, "Could not make the reservation and get the RegistrationViewModel");
        }