public static SendAcceptanceEmail ( |
||
appointment | The appointment which was approved. | |
리턴 | void |
/// <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 { string actionKeyString = this.Request.QueryString["ActionKey"]; if (string.IsNullOrEmpty(actionKeyString)) { return; } Guid actionKey; try { actionKey = new Guid(actionKeyString); } catch (FormatException) { return; } catch (OverflowException) { return; } Appointment appointment = Appointment.ApproveByKey(actionKey); if (appointment == null) { return; } if (appointment.IsAccepted == null) { this.ApprovalMessage.TextResourceKey = "UnsuccessfulAccept.Text"; return; } string resourceKey; if (appointment.IsAccepted.Value) { EmailService.SendAcceptanceEmail(appointment); resourceKey = "SuccessfulAccept.Text"; } else { EmailService.SendDeclineEmail(appointment, string.Empty); resourceKey = "SuccessfulDecline.Text"; } this.ApprovalMessage.MessageType = ModuleMessageType.Success; this.ApprovalMessage.TextResourceKey = resourceKey; } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <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); }
/// <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); }