private bool ValidateBookingSlot(BookedSlot booking) { foreach (var s in this.myBookedSlotList) { if (s.IsOverLap(booking)) { return(false); } } return(true); }
public bool BookSlot(BookedSlot booking) { if (ValidateBookingSlot(booking)) { if (this.BookedSlots == null) { this.BookedSlots = new List <BookedSlot>(); } this.BookedSlots.Add(booking); BookableBroker.Save(this); return(true); } return(false); }
private bool ValidateBookingSlot(BookedSlot booking) { if (this.BookedSlots == null) { return(true); } foreach (var s in this.BookedSlots) { if (s.IsOverLap(booking)) { return(false); } } return(true); }
public bool BookSlot(BookedSlot bookingAtempt) { if (!ValidateBookingSlot(bookingAtempt)) { return(false); } var bookable = BookableBroker.GetBookableById(bookingAtempt.BookableId); if (bookable.BookSlot(bookingAtempt)) { myBookedSlotList.Add(bookingAtempt); ConsumerBroker.Save(this); return(true); } return(false); }
public bool IsOverLap(BookedSlot booking) { if (this.Start <= booking.End && this.End >= booking.End) //new book end in range { return(true); } else if (this.Start <= booking.Start && this.End >= booking.Start) // new booking start in range { return(true); } else if (this.Start >= booking.Start && this.End <= booking.End) // new booking covers { return(true); } else if (this.Start <= booking.Start && this.End >= booking.End) //new booking contain within { return(true); } return(false); }