public ActionResult FindBedInDateRange(string startDate,string endDate)
        {
            try
            {
                DateTime startDateTime = DateTime.Parse(startDate);
                DateTime endDateTime = DateTime.Parse(endDate);
                using (var db = new DatabaseModel())
                {
                    var ordersRoom = (
                        from orderRoom in db.order_room

                        where
                             (((orderRoom.StartDate <= startDateTime) && (startDateTime < orderRoom.EndDate)) ||
                               ((orderRoom.StartDate < endDateTime) && (endDateTime <= orderRoom.EndDate)))
                        select orderRoom).ToList();

                    var ordersBed = (
                        from orderBed in db.order_bed
                        where
                             (((orderBed.StartDate <= startDateTime) && (startDateTime < orderBed.EndDate)) ||
                               ((orderBed.StartDate < endDateTime) && (endDateTime <= orderBed.EndDate)))
                        select orderBed).ToList();

                    var orderBedIds = ordersBed.Select(ob => ob.BedId).ToList();
                    var orderRoomIds = ordersRoom.Select(or => or.RoomId).ToList();

                    var freeBeds = (
                        from b in db.bed
                        where
                            ((!orderBedIds.Contains(b.Id)) &&
                             (!orderRoomIds.Contains(b.RoomId)))
                        select b
                        ).ToList();


                    var rooms = db.room.ToList();
                    var model = new ReserveModel
                    {
                        Rooms = rooms,
                        Beds = freeBeds
                    };
                    return new JsonResult
                    {
                        Data = new
                        {
                            success = true,
                            html = PartialView("_FoundBedPartial", model).RenderToString()
                        }
                    };
                }
            }
            catch (Exception e)
            {
                return new JsonResult
                {
                    Data = new
                    {
                        success = false                    
                    }
                };
            }
        }
        public ActionResult FindRoomInDateRange(string startDate, string endDate)
        {
            try
            {
                DateTime startDateTime = DateTime.Parse(startDate);
                DateTime endDateTime = DateTime.Parse(endDate);
                using (var db = new DatabaseModel())
                {
                    var ordersRoom = (
                        from orderRoom in db.order_room
                        where
                            (((orderRoom.StartDate <= startDateTime) && (startDateTime < orderRoom.EndDate)) ||
                             ((orderRoom.StartDate < endDateTime) && (endDateTime <= orderRoom.EndDate)))
                        select orderRoom);

                    var ordersBed = (
                        from orderBed in db.order_bed
                        where
                            (((orderBed.StartDate <= startDateTime) && (startDateTime < orderBed.EndDate)) ||
                             ((orderBed.StartDate < endDateTime) && (endDateTime <= orderBed.EndDate)))
                        select orderBed);

                    List<int> reservedRooms =
                        ordersRoom.Select(or => or.RoomId)
                            .Union(db.bed.Where(b => ordersBed.Any(ob => ob.BedId == b.Id)).Select(b => b.RoomId))
                            .ToList();
                        
                        /*(from orderBed in ordersBed
                        from orderRoom in ordersRoom
                        from bed in db.bed
                        from room in db.room
                        where
                            (((bed.RoomId == room.Id) &&
                              (orderBed.BedId == bed.Id)) ||
                             (orderRoom.RoomId == room.Id))
                        select room.Id
                        ).ToList();*/
                    var rooms = db.room.Where(r => !reservedRooms.Contains(r.Id)).ToList();

                    var beds = (from r in rooms
                        from b in db.bed
                        where (b.RoomId == r.Id)
                        select b
                        ).Distinct().ToList();

                    var model = new ReserveModel
                    {
                        Rooms = rooms,
                        Beds = beds
                    };
                    return new JsonResult
                    {
                        Data = new
                        {
                            success = true,
                            html = PartialView("_FoundRoomPartial", model).RenderToString()
                        }
                    };
                }
            }
            catch (Exception e)
            {
                return new JsonResult
                {
                    Data = new
                    {
                        success = false                   
                    }
                };
            }
        }