Beispiel #1
0
 private void AddLodger(Lodger lodger)
 {
     if (!Lodgers.Contains(lodger))
     {
         Lodgers.Add(lodger);
     }
 }
 public Reservation(Lodger lodger, Room room, DateTime arrivalDate, DateTime departureDate)
 {
     Renter        = lodger;
     HotelRoom     = room;
     ArrivalDate   = arrivalDate;
     DepartureDate = departureDate;
     CheckIn       = false;
     CheckOut      = false;
 }
Beispiel #3
0
 public override bool Equals(object obj)
 {
     if (obj == null || !this.GetType().Equals(obj.GetType()))
     {
         return(false);
     }
     else
     {
         Lodger lodger = (Lodger)obj;
         return((FullName == lodger.FullName) && (DateOfBirth == lodger.DateOfBirth) && (Address == lodger.Address));
     }
 }
Beispiel #4
0
        public void CheckIn(Lodger lodger, Room room, DateTime arrivalDate, DateTime departureDate)
        {
            Reservation reservations = Reservations.Where(r => r.Renter.Equals(lodger) && r.HotelRoom.Equals(room) && r.ArrivalDate == arrivalDate && r.DepartureDate == departureDate).FirstOrDefault();

            if (reservations != null)
            {
                reservations.RenterCheckIn();
            }
            else
            {
                throw new ReservationNotFoundException();
            }
        }
Beispiel #5
0
 public void MakeReservation(Lodger lodger, Room room, DateTime arrivalDate, DateTime departureDate)
 {
     AddLodger(lodger);
     if (Rooms.Contains(room))
     {
         if (Reservations.Where(r => r.HotelRoom.Equals(room) &&
                                ((r.ArrivalDate <= arrivalDate) && (r.DepartureDate >= arrivalDate) ||
                                 ((r.ArrivalDate <= departureDate) && (r.DepartureDate >= departureDate)) ||
                                 ((r.ArrivalDate >= arrivalDate) && (r.DepartureDate <= departureDate)))).Count() == 0)
         {
             Reservations.Add(new Reservation(lodger, room, arrivalDate, departureDate));
         }
         else
         {
             throw new RoomBusyException();
         }
     }
     else
     {
         throw new RoomNotFoundException();
     }
 }