public void TryBook(Booking booking) { var intersected = _bookings.Find(b => b.Period.Intersects(booking.Period)); if (intersected == null) { _bookings.Add(booking); booking.Accept(); } booking.Reject("Room already booked at this period."); }
public void TryBook(int roomNumber, Booking booking) { RoomData room; if (_rooms.TryGetValue(roomNumber, out room)) { room.TryBook(booking); } else { booking.Reject("No such room."); } }
public void Execute() { var period = new BookPeriod(_request.BeginAt, _request.EndAt); _booking = new Booking(_request.PersonName, period); _register.TryBook(_request.RoomNumber, _booking); }