public ActionResult EditRoom(long id)
        {
            Room   room   = _hotelReservationService.GetRoomById(id);
            RoomVm roomVm = new RoomVm();

            roomVm.Id          = id;
            roomVm.MaxChild    = (int)room.Maxchild;
            roomVm.NoOfAdult   = (int)room.Noofadult;
            roomVm.RoomNo      = room.Roomno;
            roomVm.Description = room.Description;

            ViewBag.roomTypes = new SelectList(_hotelReservationService.LoadAllRoomType(), "Id", "Name", room.Roomtype.Id);
            return(View(roomVm));
        }
        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 }));
            }
        }