Example #1
0
        public async Task ConfirmedReservation(IDialogContext context, IAwaitable <bool> argument)
        {
            bool isCorrect = await argument;

            if (isCorrect)
            {
                //Bắt đầu đẩy lên CSDL thông tin khách hàng và thông tin phiếu đặt phòng
                using (CustomerService customerService = new CustomerService())
                {
                    //CustomerService customerService = new CustomerService();
                    CustomerModel model = new CustomerModel();
                    model.GetDataFromCustomer(this.customer);
                    int savedCustomer = await customerService.GetIDCustomerByPassport(model.PassportNumber);

                    if (savedCustomer == 0)
                    {
                        //customerService = new CustomerService();
                        this.reservation.CustomerID = customerService.CreateCustomerReturnID(model);
                    }
                    else
                    {
                        this.reservation.CustomerID = await customerService.GetIDCustomerByPassport(model.PassportNumber);
                    }
                    //this.reservation.CustomerID = savedCustomer;
                    ReservationModel reservationModel = new ReservationModel();
                    reservationModel.GetDataFromReservation(this.reservation);
                    //using (RoomService roomService = new RoomService())
                    //{
                    //    foreach (int id in ls)
                    //    {
                    //        rooms.Add(roomService.GetRoomFromID(id));
                    //    }
                    //}
                    //this.reservation.Price = (room.Price * (((reservation.CheckOutDateTime - reservation.CheckInDateTime).Days)));
                    using (ReservationService reservationService = new ReservationService())
                    {
                        //reservationModel.Customer = model;
                        //reservationModel.Room = this.room;
                        ReservationAndRooms2 reservationAndRooms = new ReservationAndRooms2
                        {
                            ReservationViewModel = reservationModel,
                            Rooms = ls
                        };
                        ReservationModel savedreservationModel = reservationService.CreateReservationAndRooms2(reservationAndRooms);
                        await context.PostAsync("Đơn đặt phòng đã được lưu. Vui lòng mang theo giấy CMND của quý khách và các hành khách đi cùng đến khách sạn để làm thủ tục nhận phòng.\n\nCảm ơn quý khách đã chọn Khách Sạn Mai Sơn.");

                        // context.Done(true);
                    }
                }
            }
            else
            {
                var reservationDialog = new FormDialog <Reservation>(this.reservation, Reservation.BuildOrderForm, FormOptions.PromptInStart);
                context.Call(reservationDialog, this.ResumeAfterReservationDialog);
            }
        }