/// <summary> /// Reads the instance. /// </summary> /// <param name="instance">The instance.</param> public void SetValue(RegistrationInstance instance) { EnsureChildControls(); if (instance != null) { _tbName.Text = instance.Name; if (ShowActive) { _cbIsActive.Checked = instance.IsActive; } _ceDetails.Text = instance.Details; _dtpStart.SelectedDateTime = instance.StartDateTime; _dtpEnd.SelectedDateTime = instance.EndDateTime; _nbMaxAttendees.Text = instance.MaxAttendees.ToString(); _wtpRegistrationWorkflow.SetValue(instance.RegistrationWorkflowTypeId); Person contactPerson = null; if (instance.ContactPersonAlias != null && instance.ContactPersonAlias.Person != null) { contactPerson = instance.ContactPersonAlias.Person; } else if (instance.ContactPersonAliasId.HasValue) { using (var rockContext = new RockContext()) { contactPerson = new PersonAliasService(rockContext) .Queryable() .Where(p => p.Id == instance.ContactPersonAliasId.Value) .Select(p => p.Person) .FirstOrDefault(); } } _ppContact.SetValue(contactPerson); _pnContactPhone.Text = instance.ContactPhone; _ebContactEmail.Text = instance.ContactEmail; _cbCost.Text = instance.Cost.HasValue ? instance.Cost.Value.ToString() : string.Empty; _cbCost.Visible = instance.RegistrationTemplate != null && (instance.RegistrationTemplate.SetCostOnInstance ?? false); _cbMinimumInitialPayment.Text = instance.MinimumInitialPayment.HasValue ? instance.MinimumInitialPayment.Value.ToString() : string.Empty; _cbMinimumInitialPayment.Visible = instance.RegistrationTemplate != null && (instance.RegistrationTemplate.SetCostOnInstance ?? false); _cbDefaultPaymentAmount.Text = instance.DefaultPayment.HasValue ? instance.DefaultPayment.Value.ToString() : string.Empty; _cbDefaultPaymentAmount.Visible = instance.RegistrationTemplate != null && (instance.RegistrationTemplate.SetCostOnInstance ?? false); _apAccount.SetValue(instance.AccountId); _apAccount.Visible = instance.RegistrationTemplate != null && instance.RegistrationTemplate.FinancialGatewayId.HasValue; _dtpSendReminder.SelectedDateTime = instance.SendReminderDateTime; _cbReminderSent.Checked = instance.ReminderSent; _htmlRegistrationInstructions.Text = instance.RegistrationInstructions; _htmlAdditionalReminderDetails.Text = instance.AdditionalReminderDetails; _htmlAdditionalConfirmationDetails.Text = instance.AdditionalConfirmationDetails; } else { _tbName.Text = string.Empty; _cbIsActive.Checked = true; _ceDetails.Text = string.Empty; _dtpStart.SelectedDateTime = null; _dtpEnd.SelectedDateTime = null; _nbMaxAttendees.Text = string.Empty; _wtpRegistrationWorkflow.SetValue(null); _ppContact.SetValue(null); _pnContactPhone.Text = string.Empty; _ebContactEmail.Text = string.Empty; _cbCost.Text = string.Empty; _cbMinimumInitialPayment.Text = string.Empty; _cbDefaultPaymentAmount.Text = string.Empty; _apAccount.SetValue(null); _dtpSendReminder.SelectedDateTime = null; _cbReminderSent.Checked = false; _htmlRegistrationInstructions.Text = string.Empty; _htmlAdditionalReminderDetails.Text = string.Empty; _htmlAdditionalConfirmationDetails.Text = string.Empty; } }
/// <summary> /// Sets the workflow activity. /// </summary> /// <param name="activity">The value.</param> /// <param name="rockContext">The rock context.</param> /// <param name="setValues">if set to <c>true</c> [set values].</param> public void SetWorkflowActivity(WorkflowActivity activity, RockContext rockContext, bool setValues = false) { EnsureChildControls(); _hfActivityGuid.Value = activity.Guid.ToString(); _lblActivityTypeName.Text = activity.ActivityTypeCache.Name; _lblActivityTypeDescription.Text = activity.ActivityTypeCache.Description; if (activity.CompletedDateTime.HasValue) { _lblStatus.Visible = true; _lblStatus.Text = "<span class='label label-default'>Completed</span>"; } else if (activity.ActivatedDateTime.HasValue) { _lblStatus.Visible = true; _lblStatus.Text = "<span class='label label-success'>Active</span>"; } else { _lblStatus.Visible = false; _lblStatus.Text = string.Empty; } _cbActivityIsComplete.Checked = activity.CompletedDateTime.HasValue; if (activity.AssignedPersonAliasId.HasValue) { var person = new PersonAliasService(rockContext).Queryable() .Where(a => a.Id == activity.AssignedPersonAliasId.Value) .Select(a => a.Person) .FirstOrDefault(); if (person != null) { _ppAssignedToPerson.SetValue(person); _lAssignedToPerson.Text = person.FullName; } } if (activity.AssignedGroupId.HasValue) { var group = new GroupService(rockContext).Get(activity.AssignedGroupId.Value); if (group != null) { if (group.IsSecurityRole) { _ddlAssignedToRole.SetValue(group.Id); _gpAssignedToGroup.SetValue(null); _lAssignedToRole.Text = group.Name; } else { _ddlAssignedToRole.SelectedIndex = -1; _gpAssignedToGroup.SetValue(group); _lAssignedToGroup.Text = group.Name; } } } var sbState = new StringBuilder(); if (activity.ActivatedDateTime.HasValue) { sbState.AppendFormat("<strong>Activated:</strong> {0} {1} ({2})<br/>", activity.ActivatedDateTime.Value.ToShortDateString(), activity.ActivatedDateTime.Value.ToShortTimeString(), activity.ActivatedDateTime.Value.ToRelativeDateString()); } if (activity.CompletedDateTime.HasValue) { sbState.AppendFormat("<strong>Completed:</strong> {0} {1} ({2})", activity.CompletedDateTime.Value.ToShortDateString(), activity.CompletedDateTime.Value.ToShortTimeString(), activity.CompletedDateTime.Value.ToRelativeDateString()); } _lState.Text = sbState.ToString(); _phAttributes.Controls.Clear(); if (CanEdit) { Rock.Attribute.Helper.AddEditControls(activity, _phAttributes, setValues, ValidationGroup); } else { Rock.Attribute.Helper.AddDisplayControls(activity, _phAttributes); } }