Пример #1
0
        public void SaveBooking(Booking roomBooking, Bookingdetail bookingDetail, IList <Roomhistory> roomHistories, Customer customer)
        {
            ITransaction transaction = null;

            try
            {
                using (transaction = _session.BeginTransaction())
                {
                    _customerDao.Save(customer);
                    roomBooking.Customer = customer;
                    _bookingDao.Save(roomBooking);
                    foreach (var roomhistory in roomHistories)
                    {
                        roomhistory.Booking = roomBooking;
                        _roomHistoryDao.Save(roomhistory);
                    }
                    transaction.Commit();
                }
            }
            catch (Exception)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                }
                throw;
            }
        }
Пример #2
0
        protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            var           bookNumber = turnContext.Activity.Text;
            Bookingdetail statusof   = Fetchstatus(bookNumber);

            if (statusof == null)
            {
                var reply = "Sorry!! You entered an invalid booking number";
                await turnContext.SendActivityAsync(MessageFactory.Text(reply, reply), cancellationToken);

                var promptmessage = "Enter a valid booking ID ???";
                await turnContext.SendActivityAsync(MessageFactory.Text(promptmessage, promptmessage), cancellationToken);
            }

            else
            {
                var replyid = "Your booking ID  :" + statusof.Bookingid;
                await turnContext.SendActivityAsync(MessageFactory.Text(replyid, replyid), cancellationToken);

                var replydate = "Your Travel Date  :" + statusof.Date;
                await turnContext.SendActivityAsync(MessageFactory.Text(replydate, replydate), cancellationToken);

                var replyfrom = "You are travelling from  :  " + statusof.From;
                await turnContext.SendActivityAsync(MessageFactory.Text(replyfrom, replyfrom), cancellationToken);

                var replyto = "You are travelling to  :  " + statusof.Venue;
                await turnContext.SendActivityAsync(MessageFactory.Text(replyto, replyto), cancellationToken);

                var replystatus = "Your booking status  :  " + statusof.Status;
                await turnContext.SendActivityAsync(MessageFactory.Text(replystatus, replystatus), cancellationToken);

                var promptmessage = "Enter booking ID to check another status???";
                await turnContext.SendActivityAsync(MessageFactory.Text(promptmessage, promptmessage), cancellationToken);
            }
        }
        public ActionResult SaveRoomBooking(string hotelReservationObj)
        {
            try
            {
                JavaScriptSerializer serializer        = new JavaScriptSerializer();
                ReservationVm        roomReservationVm = serializer.Deserialize <ReservationVm>(hotelReservationObj);

                Booking roomBooking = new Booking();
                roomBooking.Checkindate  = roomReservationVm.CheckinDate;
                roomBooking.Checkoutdate = roomReservationVm.CheckoutDate;
                roomBooking.Noofadult    = roomReservationVm.NoOfAdult;
                roomBooking.Noofchild    = roomReservationVm.NoOfChild;

                Bookingdetail bookingDetail = new Bookingdetail();
                bookingDetail.Advanceamount = roomReservationVm.AdvanceAmount;
                bookingDetail.Billingtype   = roomReservationVm.BillingType;
                bookingDetail.Contactno     = roomReservationVm.ContactNumber;
                bookingDetail.Creditcardno  = roomReservationVm.CreditCardNo;
                bookingDetail.Email         = roomReservationVm.Email;
                bookingDetail.Firstname     = roomReservationVm.FirstName;
                bookingDetail.Lastname      = roomReservationVm.LastName;
                bookingDetail.Noofnight     =
                    roomReservationVm.CheckoutDate.Subtract(roomReservationVm.CheckinDate).Days;
                bookingDetail.Status = Roomregisterdetail.EntityStatus.Booked;
                roomBooking.Bookingdetails.Add(bookingDetail);
                bookingDetail.Booking = roomBooking;

                Customer customer = new Customer();
                customer.Firstname     = roomReservationVm.FirstName;
                customer.Lastname      = roomReservationVm.LastName;
                customer.Dob           = roomReservationVm.Dob;
                customer.Contactnumber = roomReservationVm.ContactNumber;
                customer.Email         = roomReservationVm.Email;
                customer.Address       = roomReservationVm.Address;
                customer.Nationality   = roomReservationVm.Nationality;
                customer.Nid           = roomReservationVm.Nid;
                customer.Passport      = roomReservationVm.Passport;
                customer.Remarks       = roomReservationVm.Remarks;

                IList <Roomhistory> roomHistories = new List <Roomhistory>();
                foreach (var roomId in roomReservationVm.RoomIds)
                {
                    Room room = _hotelReservationService.GetRoomById(Convert.ToInt64(roomId));
                    roomBooking.Rooms.Add(room);
                    Roomhistory roomHistory = new Roomhistory();
                    roomHistory.Arrivaldate = roomBooking.Checkindate;
                    roomHistory.Leavedate   = roomBooking.Checkoutdate;
                    roomHistory.Booking     = roomBooking;
                    roomHistory.Room        = room;
                    roomHistories.Add(roomHistory);
                }
                _hotelReservationService.SaveBooking(roomBooking, bookingDetail, roomHistories, customer);
                return(RedirectToAction("Booking", new { message = "Room Booked Successfully", type = 1 }));
            }
            catch (Exception)
            {
                return(RedirectToAction("Booking", new { message = "Failed to Booked Room", type = 2 }));
            }
        }