Load() public static method

Loads the Appointment with the specified appointmentId.
public static Load ( int appointmentId ) : Appointment
appointmentId int The ID of the to load.
return Appointment
        /// <summary>
        /// Handles the <see cref="LinkButton.Click"/> event of the <c>SubmitDeclineReasonButton</c> control in the footer of the <see cref="DeclineReasonRepeater"/>.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void SubmitDeclineReasonButton_Click(object sender, EventArgs e)
        {
            var declinedAppointments = new List <Appointment>();

            foreach (RepeaterItem repeaterItem in this.DeclineReasonRepeater.Items)
            {
                var declinedAppointmentIdHiddenField = (HiddenField)repeaterItem.FindControl("DeclinedAppointmentIdHiddenField");
                var declineReasonTextBox             = (TextBox)repeaterItem.FindControl("DeclineReasonTextBox");

                int appointmentId = int.Parse(declinedAppointmentIdHiddenField.Value, NumberStyles.Integer, CultureInfo.InvariantCulture);
                var appointment   = Appointment.Load(appointmentId);
                if (appointment != null)
                {
                    appointment.Decline(this.UserId);
                    declinedAppointments.Add(appointment);
                    EmailService.SendDeclineEmail(appointment, declineReasonTextBox.Text);
                }
            }

            this.ApprovalMessage.Visible = true;
            this.ApprovalMessage.Text    = this.GenerateAppointmentApprovalMessage(declinedAppointments, "DeclinedAppointments.Text");

            this.BindData(true);
            this.ApprovalMultiview.SetActiveView(this.ApprovalsListView);
        }
        /// <summary>
        /// Handles the <see cref="GridView.RowCommand"/> event of the <see cref="AppointmentsGrid"/> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/> instance containing the event data.</param>
        private void AppointmentsGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int appointmentId = int.Parse((string)e.CommandArgument, NumberStyles.Integer, CultureInfo.InvariantCulture);

            switch (e.CommandName)
            {
            case "Accept":
                if (!this.AcceptAppointment(appointmentId))
                {
                    this.ConflictingAppointmentsMessage.Visible         = true;
                    this.ConflictingAppointmentsMessage.TextResourceKey = "ConflictAcceptingAppointment.Text";
                }
                else
                {
                    this.ApprovalMessage.Visible         = true;
                    this.ApprovalMessage.TextResourceKey = "SuccessfulAccept.Text";
                }

                break;

            case "Decline":
                this.ApprovalMultiview.SetActiveView(this.ProvideDeclineReasonView);
                this.DeclineReasonRepeater.DataSource = new[] { Appointment.Load(appointmentId) };
                this.DeclineReasonRepeater.DataBind();
                break;
            }

            this.BindData(true);
        }
        /// <summary>
        /// Handles the <see cref="RadToolTipManager.AjaxUpdate"/> event of the <see cref="AppointmentToolTipManager"/> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.ToolTipUpdateEventArgs"/> instance containing the event data.</param>
        private void AppointmentToolTipManager_AjaxUpdate(object sender, ToolTipUpdateEventArgs e)
        {
            int appointmentId;

            if (int.TryParse(e.Value.Split('_')[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out appointmentId))
            {
                Appointment        appointment = Appointment.Load(appointmentId);
                AppointmentToolTip toolTip     = (AppointmentToolTip)this.LoadControl("AppointmentToolTip.ascx");

                toolTip.ModuleConfiguration = this.ModuleConfiguration;
                toolTip.SetAppointment(appointment);
                e.UpdatePanel.ContentTemplateContainer.Controls.Add(toolTip);
            }
        }
        /// <summary>
        /// Accepts the <see cref="Appointment"/> with the given <paramref name="appointmentId"/>,
        /// and sends an email to the requestor of the <see cref="Appointment"/>.
        /// </summary>
        /// <param name="appointmentId">The ID of the appointment to accept.</param>
        /// <returns>Whether the appointment was able to be successfully accepted</returns>
        private bool AcceptAppointment(int appointmentId)
        {
            var appointment = Appointment.Load(appointmentId);

            if (appointment != null)
            {
                if (this.TryAcceptAppointment(this.UserId, appointment))
                {
                    EmailService.SendAcceptanceEmail(appointment);
                    return(true);
                }
            }

            return(false);
        }
Beispiel #5
0
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (this.AppointmentId.HasValue)
         {
             var appointment = Appointment.Load(this.AppointmentId.Value);
             if (appointment != null && appointment.ModuleId == this.ModuleId)
             {
                 this.FillAppointmentInformation(appointment);
             }
         }
     }
     catch (Exception exc)
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
        /// <summary>
        /// Handles the <see cref="Button.Click"/> event of the <see cref="AcceptAppointmentsButton"/> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void AcceptAppointmentsButton_Click(object sender, EventArgs e)
        {
            var conflictingAppointments = new List <Appointment>();
            var acceptedAppointments    = new List <Appointment>();
            var appointmentIds          = this.GetSelectedAppointmentIds();

            foreach (var appointmentId in appointmentIds)
            {
                var appointment = Appointment.Load(appointmentId);
                if (appointment != null)
                {
                    if (this.TryAcceptAppointment(this.UserId, appointment))
                    {
                        EmailService.SendAcceptanceEmail(appointment);
                        acceptedAppointments.Add(appointment);
                    }
                    else
                    {
                        conflictingAppointments.Add(appointment);
                    }
                }

                if (acceptedAppointments.Count > 0)
                {
                    this.ApprovalMessage.Visible = true;
                    this.ApprovalMessage.Text    = this.GenerateAppointmentApprovalMessage(acceptedAppointments, "AcceptedAppointments.Text");
                }
            }

            if (conflictingAppointments.Count > 0)
            {
                this.ConflictingAppointmentsMessage.Visible = true;
                this.ConflictingAppointmentsMessage.Text    = this.GenerateAppointmentApprovalMessage(conflictingAppointments, "ConflictAcceptingAppointments.Text");
            }

            this.BindData(true);
        }
        /// <summary>
        /// Handles the <see cref="Button.Click"/> event of the <see cref="DeclineAppointmentsButton"/> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void DeclineAppointmentsButton_Click(object sender, EventArgs e)
        {
            this.ApprovalMultiview.SetActiveView(this.ProvideDeclineReasonView);
            List <Appointment> selectedAppointments = this.GetSelectedAppointmentIds().ConvertAll(appointmentId => Appointment.Load(appointmentId));

            this.DeclineReasonRepeater.DataSource = selectedAppointments;
            this.DeclineReasonRepeater.DataBind();
        }