public Booking(User client, DateTime startBookDate, DateTime endBookDate, decimal totalPrice, string comments) { if (endBookDate < startBookDate) { throw new ArgumentException("The date range is invalid."); } this.Client = client; this.availableDate = new AvailableDate(startBookDate, endBookDate); this.TotalPrice = totalPrice; this.Comments = comments; }
// TODO: This works, don't touch! private void UpdateRoomAvailability(DateTime startDate, DateTime endDate, Room room, AvailableDate availablePeriod) { room.AvailableDates.Remove(availablePeriod); var periodBeforeBooking = startDate - availablePeriod.StartDate; if (periodBeforeBooking > TimeSpan.Zero) { room.AvailableDates.Add(new AvailableDate(availablePeriod.StartDate, availablePeriod.StartDate.Add(periodBeforeBooking))); } var periodAfterBooking = availablePeriod.EndDate - endDate; if (periodAfterBooking > TimeSpan.Zero) { room.AvailableDates.Add(new AvailableDate(availablePeriod.EndDate.Subtract(periodAfterBooking), availablePeriod.EndDate)); } }