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); }
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)); }
public ReservationRoom UpdateRoom(ReservationRoom updatedReservationRoom) { ReservationValidators.ValidIfReservationRoomExistInReservation(this, updatedReservationRoom); var reservationRoom = ReservationRooms.FirstOrDefault(x => x.Id == updatedReservationRoom.Id); return(reservationRoom.Update(updatedReservationRoom)); }
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); }
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; }
public void RemoveGuestFromRoom(ReservationRoom reservationRoom, Guest guest) { ReservationValidators.ValidIfReservationRoomExistInReservation(this, reservationRoom); reservationRoom.RemoveGuest(guest); }