/// <summary>
        /// Sends an e-mail message with the contents of the form when submitted.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OnSubmit(object sender, EventArgs e)
        {
            StringBuilder  body = new StringBuilder();
            MembershipUser user = Membership.GetUser();

            body.AppendLine("Sender Details:");
            body.AppendLine("---------------");
            body.AppendFormat("{0} Username: {1}\r\n", CPProviders.SettingsProvider.ApplicationName, user.UserName);
            body.AppendLine("Candidate ID: " + CPProfile.Cid);
            body.AppendLine("Candidate Name: " + CPProfile.ActiveCandidate.Name);
            body.AppendLine("Election Cycle: " + CPProfile.ElectionCycle);
            body.AppendLine("---------------");
            body.AppendLine();
            body.AppendLine("Message Details:");
            body.AppendLine("----------------");
            body.AppendLine(Message.Text);
            // assemble message
            CPMailMessage message = new CPMailMessage();

            message.Recipient = new MailAddress(CPApplication.CsuEmail);
            message.Sender    = CPProfile.GetMailAddress();
            message.Subject   = _subject;
            message.Body      = body.ToString();
            // send message
            message.Send();
            _contactForm.Visible  = false;
            _confirmation.Visible = true;
        }
Exemple #2
0
        protected void OnSubmit(object sender, EventArgs e)
        {
            string toEmail;
            string subject;

            switch (Category.SelectedValue.ToLowerInvariant())
            {
            case "audit":
                toEmail = CPApplication.AuditEmail;
                subject = Resources.CPResources.audit_email_subject;
                break;

            case "csu":
                toEmail = CPApplication.CsuEmail;
                subject = Resources.CPResources.csu_email_subject;
                break;

            default:
                toEmail = CPApplication.GeneralEmail;
                subject = Resources.CPResources.general_email_subject;
                break;
            }
            MembershipUser user = Membership.GetUser(User.Identity.Name);
            StringBuilder  body = new StringBuilder();

            body.AppendLine("Sender Details:");
            body.AppendLine("---------------");
            body.AppendFormat("{0} Username: {1}\r\n", CPProviders.SettingsProvider.ApplicationName, user.UserName);
            body.AppendLine("Candidate ID: " + CPProfile.Cid);
            body.AppendLine("Candidate Name: " + CPProfile.ActiveCandidate.Name);
            body.AppendLine("Election Cycle: " + CPProfile.ElectionCycle);
            body.AppendLine("---------------");
            body.AppendLine();
            body.AppendLine("Message Details:");
            body.AppendLine("----------------");
            body.AppendLine(Message.Text);
            // assemble message
            CPMailMessage message = new CPMailMessage();

            message.Sender    = CPProfile.GetMailAddress();
            message.Recipient = new MailAddress(toEmail);
            message.Subject   = subject;
            message.Body      = body.ToString();
            // send message
            message.Send();
            _contactForm.Visible  = false;
            _confirmation.Visible = true;
        }
 /// <summary>
 /// Handles password change attempts and updates page contents accordingly.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">An <see cref="EventArgs" /> that contains the event data.</param>
 protected void SubmitChange(object sender, EventArgs e)
 {
     _wrongPasswordMessage.Visible      = false;
     _usernameAsPasswordMessage.Visible = false;
     if (Page.IsValid)
     {
         var user = this.CPUser;
         if (_newPassword.Text.Equals(user.UserName, StringComparison.InvariantCultureIgnoreCase))
         {
             _usernameAsPasswordMessage.Visible = true;
         }
         else
         {
             if (user.ChangePassword(_currentPassword.Text, _newPassword.Text)) // TODO: implement ChangePassword security service web method
             {
                 // unexpire the password
                 if (user != null && user.PasswordExpired)
                 {
                     user.PasswordExpired = false;
                     user = CPSecurity.Provider.UpdateUser(user).User;
                 }
                 // present success confirmation
                 _changePasswordPanel.Visible = false;
                 _successPanel.Visible        = true;
                 if (Request.IsPitStop())
                 {
                     this.ReturnToHomeLink.NavigateUrl = Request.GetReturnUrl();
                     this.ReturnToHomeLink.Text        = this.ReturnToHomeLink.ToolTip = "Continue";
                 }
                 // send confirmation e-mail
                 CPMailMessage message = new CPMailMessage();
                 MailAddress   email   = CPProfile.GetMailAddress();
                 message.Recipient = email;
                 message.Subject   = _emailSubject;
                 message.Body      = string.Format(_bodyFormat, email.DisplayName, CPProviders.SettingsProvider.ApplicationName, CPProviders.SettingsProvider.ApplicationUrl, CPProviders.SettingsProvider.AgencyPhoneNumber);
                 message.Send();
                 // BUGFIX #18 - re-add authentication cookie
                 FormsAuthentication.SetAuthCookie(user.UserName, false);
             }
             else
             {
                 _wrongPasswordMessage.Visible = true;
             }
         }
     }
 }
Exemple #4
0
        /// <summary>
        /// Sends a new account request for the currently loaded contact.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="CommandEventArgs"/> that contains the event data.</param>
        protected void RequestAccountCommand(object sender, CommandEventArgs e)
        {
            string contactType = "Unknown";

            switch (e.CommandName)
            {
            case LiaisonCommandName:
            case TreasurerCommandName:
            case ConsultantCommandName:
            case CandidateCommandName:
                contactType = e.CommandName;
                break;
            }
            // send access request for user via e-mail
            StringBuilder  body           = new StringBuilder();
            MembershipUser requestor      = Membership.GetUser();
            MailAddress    requestorEmail = CPProfile.GetMailAddress();

            body.AppendFormat("{0} user {1} (username: {2}) has requested an additional account for the following campaign contact:", CPProviders.SettingsProvider.ApplicationName, requestorEmail.DisplayName, requestor.UserName);
            body.AppendLine();
            body.AppendLine();
            body.AppendLine("First Name: " + (_firstNameResult.Text = _firstName.Text));
            body.AppendLine("Middle Initial: " + (_miResult.Text = _mi.Text));
            body.AppendLine("Last Name: " + (_lastNameResult.Text = _lastName.Text));
            body.AppendLine("E-mail Address: " + (_emailResult.Text = _email.Text));
            body.AppendLine();
            body.AppendLine("Candidate ID: " + CPProfile.Cid);
            body.AppendLine("Contact Type: " + contactType);
            // assemble message
            CPMailMessage message = new CPMailMessage();

            message.Sender    = requestorEmail;
            message.Recipient = new MailAddress(CPApplication.CsuEmail);
            message.Subject   = string.Format(_subjectFormat, CPProviders.SettingsProvider.ApplicationName, CPProfile.ActiveCandidate.Name);
            message.Body      = body.ToString();
            // send message
            message.Send();
            _successPanel.Visible   = true;
            _contactDetails.Visible = _contactSelection.Visible = false;
        }
Exemple #5
0
        public ActionResult SubmitAccountRequest(string id)
        {
            if (!Request.IsAjaxRequest())
            {
                return(RedirectToAction(ActionName_AccountRequest));
            }

            var rawData = CPProfile.AnalysisResults;
            var contact = (from c in rawData.EligibleContacts
                           where c.Key == id
                           select HelpViewModelFactory.CampaignContactFrom(c.Key, c.Value, CPProfile.Cid)).Single();

            // assemble message
            StringBuilder body           = new StringBuilder();
            MailAddress   requestorEmail = CPProfile.GetMailAddress();

            body.AppendFormat("{0} user {1} (username: {2}) has requested an additional account for the following campaign contact:", CPProviders.SettingsProvider.ApplicationName, requestorEmail.DisplayName, User.Identity.Name);
            body.AppendLine();
            body.AppendLine();
            body.AppendFormat("First Name: {0}", contact.FirstName);
            body.AppendFormat("Middle Initial: {0}", contact.MiddleInitial);
            body.AppendFormat("Last Name: {0}", contact.LastName);
            body.AppendFormat("E-mail Address: {0}", contact.Email);
            body.AppendLine();
            body.AppendLine("Candidate ID: " + CPProfile.Cid);
            body.AppendLine("Contact Type: " + contact.Type);
            using (CPMailMessage message = new CPMailMessage
            {
                Sender = requestorEmail,
                Recipient = new MailAddress(CPApplication.CsuEmail),
                Subject = string.Format("{0} Account Request (Candidate: {1})", CPProviders.SettingsProvider.ApplicationName, CPProfile.ActiveCandidate.Name),
                Body = body.ToString()
            })
            {
                //message.Send();
            }

            return(PartialView("_AccountRequestConfirmation"));
        }
Exemple #6
0
 /// <summary>
 /// Attempts to submit the current extension request.
 /// </summary>
 /// <returns>true if the extension request was successfully submitted; otherwise, false.</returns>
 private bool SubmitExtensionRequest()
 {
     try
     {
         byte     number;
         DateTime dueDate;
         DateTime requestedDate;
         if (TryParseReviewNumberListItemValue(_numberDropDown.SelectedValue, out number, out dueDate) && DateTime.TryParse(_dueDateDropDown.SelectedValue, out requestedDate))
         {
             Extension req = Extension.Add(CPProfile.Cid, _electionCycle.Text, CPConvert.ParseEnum <ExtensionType>(_types.SelectedValue), number, DateTime.Now, requestedDate, _reason.Text);
             if (req != null)
             {
                 // send e-mail notification
                 CPMailMessage message = new CPMailMessage();
                 message.Sender = CPProfile.GetMailAddress();
                 message.To.Add(CPApplication.AuditExtensionRequestsEmail);
                 message.IsBodyHtml = true;
                 message.Subject    = string.Format("Request for Extension to EC{0} {1} {2}", req.ElectionCycle, _typesValue.Text, req.ReviewNumber);
                 message.Body       = string.Format(EmailBodyFormat,
                                                    Cfis.GetCandidateName(CPProfile.Cid, true),
                                                    CPProfile.Cid,
                                                    message.Sender.DisplayName,
                                                    User.Identity.Name,
                                                    req.ElectionCycle,
                                                    _typesValue.Text,
                                                    _numberLabelText.Text,
                                                    _numberValue.Text,
                                                    _dueDateValue.Text);
                 message.Send();
                 return(true);
             }
         }
     }
     catch
     {
     }
     return(false);
 }
Exemple #7
0
        /// <summary>
        /// Handles paper delivery setting changes and updates page contents accordingly.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">An <see cref="CommandEventArgs" /> that contains the event data.</param>
        protected void SubmitChange(object sender, CommandEventArgs e)
        {
            if (Page.IsPostBack)
            {
                // check what action was just requested
                switch (e.CommandName)
                {
                case StopPaperCommandName:
                    switch (e.CommandArgument as string)
                    {
                    case StopPaperCommandArgument:
                        // check for verification options and stop paper
                        if (Page.IsValid)
                        {
                            bool success = false;
                            if (_settings == null)
                            {
                                _settings = CmoSettings.Add(CPProfile.Cid, true, User.Identity.Name);
                                success   = _settings != null;
                            }
                            else
                            {
                                _settings.IsPaperless     = true;
                                _settings.UpdaterUserName = User.Identity.Name;
                                success = _settings.Update();
                            }
                            if (success)
                            {
                                ShowPaperStopped();
                            }
                            else
                            {
                                this.ShowSaveError();
                            }
                        }
                        else
                        {
                            _validationSummary.Visible = true;
                        }
                        break;

                    default:
                        // show verification options
                        ShowStopPaperVerification();
                        break;
                    }
                    break;

                case ResumePaperCommandName:
                    // resume paper
                    if (_settings == null)
                    {
                        _settings = CmoSettings.Add(CPProfile.Cid, false, User.Identity.Name);
                        if (_settings != null)
                        {
                            ShowDeferComplete();
                        }
                        else
                        {
                            this.ShowSaveError();
                        }
                    }
                    else
                    {
                        _settings.IsPaperless     = false;
                        _settings.UpdaterUserName = User.Identity.Name;
                        if (_settings.Update())
                        {
                            ShowPaperResumed();
                        }
                        else
                        {
                            this.ShowSaveError();
                        }
                    }
                    break;
                }
                // TODO: send confirmation e-mail
                CPMailMessage message = new CPMailMessage();
                MailAddress   email   = CPProfile.GetMailAddress();
                message.Recipient = email;
                message.Subject   = _emailSubject;
                message.Body      = string.Format(_optInBodyFormat, email.DisplayName, CPProviders.SettingsProvider.ApplicationName, CPApplication.SiteUrl);
                //message.Send();
            }
        }