protected override string GetCurrentValue() { var email = _Page.GetVolunteerToEdit(); if (Column == "PartyCode") { return(VolunteersView.GetPartyKey(email).Substring(2)); } var column = VolunteersView.GetColumn(Column); var value = VolunteersView.GetColumn(column, email); return(value == null ? string.Empty : ToDisplay(value)); }
protected void ButtonAddVolunteer_OnClick(object sender, EventArgs e) { try { _AddVolunteerTabInfo.ClearValidationErrors(); var success = _AddVolunteerTabInfo.Validate(); if (!success) { return; } // check for existing email var email = ControlAddVolunteerEmail.GetValue(); var isVolunteer = PartiesEmails.GetIsVolunteer(email); if (isVolunteer != null) { // duplicate FeedbackAddVolunteer.PostValidationError(ControlAddVolunteerEmail, isVolunteer.Value ? "The email address is already registered as a volunteer" : "The email address is registered as a party official"); return; } var password = ControlAddVolunteerPassword.GetValue().Trim(); if (string.IsNullOrWhiteSpace(password)) { password = MakeUniquePassword(); } VolunteersView.Insert(email, password, ControlAddVolunteerState.GetValue() + ControlAddVolunteerParty.GetValue(), ControlAddVolunteerFirstName.GetValue(), ControlAddVolunteerLastName.GetValue(), ControlAddVolunteerPhone.GetValue().Trim()); var notes = ControlAddVolunteerNotes.GetValue().StripRedundantWhiteSpace(); if (!string.IsNullOrWhiteSpace(notes)) { VolunteersNotes.Insert(email, DateTime.UtcNow, notes); } _AddVolunteerTabInfo.Reset(); FeedbackAddVolunteer.AddInfo("Volunteer added."); } catch (Exception ex) { FeedbackAddVolunteer.HandleException(ex); } }
protected override bool Update(object newValue) { var email = _Page.GetVolunteerToEdit(); if ((Column == "StateCode") || (Column == "PartyCode")) { var partyKey = _Page.ControlEditVolunteerStateCode.GetValue() + _Page.ControlEditVolunteerPartyCode.GetValue(); VolunteersView.UpdatePartyKey(partyKey, email); } else { var column = VolunteersView.GetColumn(Column); VolunteersView.UpdateColumn(column, newValue, email); } if (Column == "Email") { // update notes VolunteersNotes.UpdateEmailByEmail(newValue as string, email); } return(true); }
protected void ButtonEditVolunteer_OnClick(object sender, EventArgs e) { switch (EditVolunteerReloading.Value) { case "reloading": { EditVolunteerReloading.Value = Empty; RefreshReport.Value = "N"; var stateCode = VolunteersView.GetStateCode(GetVolunteerToEdit()).SafeString(); StateCache.Populate(ControlEditVolunteerStateCode, stateCode); Parties.PopulateNationalParties(ControlEditVolunteerPartyCode, true, null, true, null); //LoadEditParties(stateCode); _EditVolunteerDialogInfo.LoadControls(); //LoadEditUndos(); FeedbackEditVolunteer.AddInfo("Volunteer information loaded."); } break; case "": { // normal update _EditVolunteerDialogInfo.ClearValidationErrors(); _EditVolunteerDialogInfo.Update(FeedbackEditVolunteer); var emailItem = _EditVolunteerDialogInfo.FirstOrDefault(i => i.Column == "Email"); if (!emailItem?.DataControl.HasClass("error") == true) { VolunteerToEdit.Value = DataItemBase.GetCurrentValue(emailItem); } RefreshReport.Value = "Y"; //LoadEditUndos(); } break; default: throw new VoteException( $"Unknown reloading option: '{EditVolunteerReloading.Value}'"); } }
private void SubmitCallback(Dictionary <string, string> dict) { var email = dict["EmailFormFromEmailAddress"]; var isVolunteer = PartiesEmails.GetIsVolunteer(email); if (isVolunteer != null) // email exists { throw new VoteException(isVolunteer.Value ? "This email address is already registered to a volunteer" : "This email address is registered to a party official"); } var subject = dict["EmailFormSubject"]; var message = dict["EmailFormMessage"]; var firstName = dict["EmailFormFirstName"]; var lastName = dict["EmailFormLastName"]; var partyCode = dict["EmailFormParty"]; var stateCode = dict["EmailFormState"]; var phone = dict["EmailFormPhone"]; var password = dict["EmailFormPassword"]; var dateStamp = DateTime.UtcNow; if (IsNullOrWhiteSpace(password)) { password = MakeUniquePassword(); } // for email display EmailForm.SetOptionalValue("EmailFormParty", Parties.GetNationalPartyDescription(partyCode)); EmailForm.SetOptionalValue("EmailFormPassword", password); VolunteersView.Insert(email, password, stateCode + partyCode, firstName, lastName, phone); VolunteersNotes.Insert(email, dateStamp, subject); if (!IsNullOrWhiteSpace(message)) { VolunteersNotes.Insert(email, dateStamp.AddSeconds(1), message); } }