예제 #1
0
        internal ReservationRoom Update(ReservationRoom updatedReservationRoom)
        {
            if (updatedReservationRoom.Room != Room)
            {
                throw new HotelException("Nie można zmieniać pokoju.");
            }

            if (updatedReservationRoom.Reservation != Reservation)
            {
                throw new HotelException("Nie można zmieniać przypisanej rezerwacji.");
            }

            if (!updatedReservationRoom.Guests?.Any() ?? true)
            {
                throw new HotelException("Należy przypisać gości do pokoju.");
            }

            var joined = (from guest in Guests
                          join updatedGuest in updatedReservationRoom.Guests on guest.Id equals updatedReservationRoom.Id
                          select new { guest, updatedGuest }).ToList();

            joined.ForEach(x => x.guest.Update(x.updatedGuest));

            return(this);
        }
예제 #2
0
        public Guest AddGuestToRoom(ReservationRoom reservationRoom, string name, bool isChild,
                                    bool isNewlyweds, bool orderedBreakfest, decimal priceForStay)
        {
            ReservationValidators.ValidIfReservationRoomExistInReservation(this, reservationRoom);

            return(reservationRoom.AddGuest(name, isChild, isNewlyweds, orderedBreakfest, priceForStay));
        }
예제 #3
0
        public ReservationRoom UpdateRoom(ReservationRoom updatedReservationRoom)
        {
            ReservationValidators.ValidIfReservationRoomExistInReservation(this, updatedReservationRoom);

            var reservationRoom = ReservationRooms.FirstOrDefault(x => x.Id == updatedReservationRoom.Id);

            return(reservationRoom.Update(updatedReservationRoom));
        }
예제 #4
0
        public void AddRoom(Room room)
        {
            if (ReservationRooms.Any(x => x.Room == room))
            {
                throw new HotelException($"Pokój {room} już istnieje w tej rezerwacji.");
            }

            var reservationRoom = new ReservationRoom(this, room);

            ReservationRooms.Add(reservationRoom);
        }
예제 #5
0
파일: Guest.cs 프로젝트: grofab95/Hotel
        internal Guest(string name, bool isChild, bool isNewlyweds, bool orderedBreakfest, decimal basePrice, ReservationRoom reservationRoom)
        {
            GuestValidators.ValidIfNameExist(name);
            GuestValidators.ValidPrice(basePrice);

            Name             = name;
            IsChild          = isChild;
            IsNewlyweds      = isNewlyweds;
            OrderedBreakfest = orderedBreakfest;
            BasePrice        = basePrice;
            ReservationRoom  = reservationRoom;
        }
예제 #6
0
        public void RemoveGuestFromRoom(ReservationRoom reservationRoom, Guest guest)
        {
            ReservationValidators.ValidIfReservationRoomExistInReservation(this, reservationRoom);

            reservationRoom.RemoveGuest(guest);
        }