Example #1
0
        public bool BookingDetails(BookingVM bookingVM)
        {
            //check hotel name and room name

            HotelDL hotelDL = new HotelDL();
            RoomDL  roomDL  = new RoomDL();

            bool isExistHotelName = hotelDL.CheckHotelName(bookingVM.HotelName);
            bool isExistRoomName  = roomDL.CheckRoomName(bookingVM.RoomName);

            if (isExistHotelName == true && isExistRoomName == true)
            {
                int hotelId = hotelDL.GetHotelAscending()
                              .Where(x => x.HotelName == bookingVM.HotelName)
                              .Select(x => x.HotelId)
                              .FirstOrDefault();;

                int roomId = roomDL.GetRooms()
                             .Where(x => x.RoomName == bookingVM.RoomName && x.HotelId == hotelId)
                             .Select(x => x.RoomId)
                             .FirstOrDefault();;

                bookingVM.HotelId = hotelId;
                bookingVM.RoomId  = roomId;

                List <BookingVM> bookingVMs = new List <BookingVM>();
                bookingVMs.Add(bookingVM);
                bool saveStatus = bookingDL.SaveBookings(bookingVM);
                return(saveStatus);
            }
            return(false);
        }