コード例 #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);
        }