public IEnumerable <Room> EmptyRooms(DateTime startDate, DateTime endDate) { var res = Reservations.Where(i => i.Key.StartDate <= endDate && i.Key.EndDate >= startDate). Select(i => i.Key.RoomNumber); return(Rooms.Except(Rooms.Where(i => res.Contains(i.Number)))); }
private void LoadDataFromModel() { //Points.Clear(); //Lines.Clear(); //Rooms.Clear(); //Points.Clear(); //Lines.Clear(); //Rooms.Clear(); List <MyPoint> common = Points.Intersect(model.ModelPoints).ToList(); List <MyPoint> diff = model.ModelPoints.Except(common).ToList(); List <MyPoint> diffBAD = Points.Except(model.ModelPoints).ToList(); foreach (MyPoint point in diffBAD) { Points.Remove(point); } foreach (MyPoint point in diff) { Points.Add(point); } List <MyLine> commonL = Lines.Intersect(model.modelLines).ToList(); List <MyLine> diffL = model.modelLines.ToList().Except(commonL).ToList(); List <MyLine> diffLBAD = Lines.Except(model.modelLines).ToList(); foreach (MyLine line in diffLBAD) { Lines.Remove(line); } foreach (MyLine line in diffL) { Lines.Add(line); } List <MyRoom> commonR = Rooms.Intersect(model.modelRooms).ToList(); List <MyRoom> diffR = model.modelRooms.ToList().Except(commonR).ToList(); List <MyRoom> diffRBAD = Rooms.Except(model.modelRooms).ToList(); foreach (MyRoom room in diffRBAD) { Rooms.Remove(room); } foreach (MyRoom room in diffR) { Rooms.Add(room); } //foreach (MyLine line in model.modelLines) { // Lines.Add(line); //} //foreach (MyRoom room in model.modelRooms) { // Rooms.Add(room); //} }
public List <string> GetAvaliableRooms(DateTime date) { //Find all rooms that have a slot on the specific date. var roomsWithSlots = GetSlotsOnDate(date).Select(x => x.RoomName); //Find the rooms which have been booked twice, which is the maximum number of bookings allowed. var roomsWithMultipleSlots = roomsWithSlots.Where(x => GetSlotsOnDate(date).Count(y => y.RoomName == x) >= 2); //Return the rooms which do not have the max number of bookings. return(Rooms.Except(roomsWithMultipleSlots).ToList()); }