Example #1
0
        public IEnumerable <Room> GetAllFreeRooms(RoomFreeBl room)
        {
            // return _context.Room.FromSqlRaw($"select * from AllFreeRomms({left}, {right})").AsNoTracking().ToList();
            //            select* from[dbo].[Room]
            //            where id not iN(select id_room from[dbo].[Handling]
            //where (inCheck<@left AND outCheck> @right) or(inCheck<@right ))
            var sub = (from tab2 in _context.Handling
                       where ((tab2.InCheck > room.InCheck) && (tab2.OutCheck < room.OutCheck)) || ((tab2.InCheck < room.InCheck) && (tab2.OutCheck > room.InCheck)) || ((tab2.InCheck < room.OutCheck) && (tab2.OutCheck > room.OutCheck))
                       //where tab2.InCheck < left && tab2.OutCheck > right
                       select tab2.IdRoom).ToList();

            return(_context.Room.Where(w => !sub.Contains(w.Id)).ToList());
        }
Example #2
0
        public IEnumerable <RoomBl> GetAllFreeRoomsWithProp(RoomFreeBl room)
        {
            var sub = (from tab2 in _context.Handling
                       where ((tab2.InCheck > room.InCheck) && (tab2.OutCheck < room.OutCheck)) || ((tab2.InCheck < room.InCheck) && (tab2.OutCheck > room.InCheck)) || ((tab2.InCheck < room.OutCheck) && (tab2.OutCheck > room.OutCheck))
                       //where tab2.InCheck < left && tab2.OutCheck > right
                       select tab2.IdRoom).ToList();



            var allRooms = (List <RoomBl>)GetAllRoomsWithProp();

            return(allRooms.Where(w => !sub.Contains(w.Id) && w.Type == room.Type).ToList());
        }