public static CanCreateAt ( int moduleId, System.DateTime start, System.DateTime end, int max ) : bool | ||
moduleId | int | The ID of the module in which the appointment is to be created. |
start | System.DateTime | The start of the new |
end | System.DateTime | The end of the new |
max | int | The maximum appointments allowed for the specified time range |
return | bool |
/// <summary> /// Handles the <see cref="CustomValidator.ServerValidate"/> event of the <see cref="UniqueTimeslotValidator"/> control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="args">The <see cref="System.Web.UI.WebControls.ServerValidateEventArgs"/> instance containing the event data.</param> private void UniqueTimeslotValidator_ServerValidate(object source, ServerValidateEventArgs args) { if (!this.StartDateTimePicker.SelectedDate.HasValue || !this.EndDateTimePicker.SelectedDate.HasValue) { return; } args.IsValid = Appointment.CanCreateAt( this.ModuleId, this.StartDateTimePicker.SelectedDate.Value, this.EndDateTimePicker.SelectedDate.Value, ModuleSettings.MaximumConcurrentAppointments.GetValueAsInt32For(this).Value); }
/// <summary> /// Attempts to accept the appointment /// </summary> /// <param name="revisingUserId">The revising user's id.</param> /// <param name="apt">The appointment to accept.</param> /// <returns><c>true</c> if an <see cref="Appointment"/> can be accepted. Else, <c>false</c>.</returns> private bool TryAcceptAppointment(int revisingUserId, Appointment apt) { var canCreate = Appointment.CanCreateAt( this.ModuleId, apt.StartDateTime, apt.EndDateTime, ModuleSettings.MaximumConcurrentAppointments.GetValueAsInt32For(this).Value); if (!canCreate) { return(false); } apt.Accept(revisingUserId); return(true); }