Beispiel #1
0
        public static Booking Create(DateTime start, int duration, RoomType type)
        {
            DateTime end = start.AddDays(duration);
            IEnumerable<Room> eligableRooms = from room in Room.Rooms where room.Type.Equals(type) select room;

            foreach (Room eligableRoom in eligableRooms){
                Booking preliminaryBooking = new Booking(start, end, null, eligableRoom);
                if (!IsBooked(preliminaryBooking)){
                    return preliminaryBooking;
                }
            }
            throw new OutOfRoomException("No more rooms!");
        }
Beispiel #2
0
 public Room(int number, RoomType type)
 {
     Number = number;
     Type   = type;
 }
Beispiel #3
0
        private static Booking MakeBooking(int chosenStartDate, int chosenNumberOfDays, RoomType type)
        {
            Booking booking;

            try{
                booking = Booking.Create(new DateTime(2013, 4, chosenStartDate), chosenNumberOfDays, type);
            }
            catch (OutOfRoomException) {
                return(null);
            }
            return(booking);
        }
Beispiel #4
0
 private static Booking MakeBooking(int chosenStartDate, int chosenNumberOfDays, RoomType type)
 {
     Booking booking;
     try{
         booking = Booking.Create(new DateTime(2013, 4, chosenStartDate), chosenNumberOfDays, type);
     }
     catch (OutOfRoomException){
         return null;
     }
     return booking;
 }
Beispiel #5
0
 public Room(int number, RoomType type)
 {
     Number = number;
     Type = type;
 }