Exemple #1
0
 internal Reservation(BookingPeriod bookingPeriod, ClientInfo client, Room room, int guestsCount)
 {
     ValidateGuestsCount(room, guestsCount);
     this.PrimaryClientInfo = client;
     this.BookingPeriod     = bookingPeriod;
     this.Room        = room;
     this.GuestsCount = guestsCount;
 }
Exemple #2
0
        public bool TryBook(BookingPeriod period, Person person, Room room, int guestCount)
        {
            var  reservation = new Reservation(period, new ClientInfo(person), room, guestCount);
            bool canBook     = this.IsRoomAvailableForPeriod(reservation.Room.Type, reservation.BookingPeriod);

            if (!canBook && this.IsOpen)
            {
                return(canBook);
            }

            this._reservations.Add(reservation);
            return(canBook);
        }
Exemple #3
0
 private bool IsPeriodAvailable(BookingPeriod bookingPeriod)
 => this.Reservations.All(x => !x.BookingPeriod.OverlapWith(bookingPeriod));
Exemple #4
0
 public bool IsRoomAvailableForPeriod(RoomType roomType, BookingPeriod bookingPeriod)
 => !this.Reservations.Any() || this.Reservations.Where(x => x.Room.Type == roomType && IsPeriodAvailable(bookingPeriod)).Any();
 public bool OverlapWith(BookingPeriod bookingPeriod)
 => this.CheckIn.Date <bookingPeriod.CheckOut.Date && this.CheckOut.Date> bookingPeriod.CheckIn.Date;