示例#1
0
        private static string CreateMailBody(Models.PersonalDetailsModel personalDetails, Models.CoverDetailsModel coverDetails)
        {
            //Gonna do a lot of append stuff for building a text email,
            // so totally not gonna do "string += string"
            var sb = new System.Text.StringBuilder();

            sb.AppendLineFormat("New submission from \"{0} {1}\"", personalDetails.FirstName, personalDetails.LastName);
            sb.AppendLine();
            sb.AppendLineFormat("Email address: {0}", personalDetails.EmailAddress);
            sb.AppendLineFormat("Primary phone Number: {0}", personalDetails.PrimaryPhoneNumber);
            sb.AppendLine();
            sb.AppendLine("Reason for applying:");
            sb.AppendLine(coverDetails.ReasonForApplying);
            sb.AppendLine();
            sb.AppendLine("Why should we hire you:");
            sb.AppendLine(coverDetails.ReasonForAcceptance);

            return(sb.ToString());
        }
示例#2
0
        private static System.Net.Mail.MailMessage CreateMail(Models.PersonalDetailsModel personalDetails, Models.CoverDetailsModel coverDetails)
        {
            var mailTo      = ConfigurationManager.AppSettings[cMailTo] ?? string.Empty;
            var mailFrom    = ConfigurationManager.AppSettings[cMailFrom] ?? string.Empty;
            var mailSubject = ConfigurationManager.AppSettings[cMailSubject] ?? string.Empty;

            //Create a shorter objectRef for smaller code :)
            var attachFile = coverDetails.CurriculumVitae;

            //Create the Mail Object
            var mail = new System.Net.Mail.MailMessage(mailFrom, mailTo);

            mail.Subject    = mailSubject;
            mail.IsBodyHtml = false;
            mail.Body       = CreateMailBody(personalDetails, coverDetails);
            mail.Attachments.Add(new System.Net.Mail.Attachment(attachFile.InputStream, attachFile.FileName));

            return(mail);
        }
示例#3
0
        public ActionResult PersonalDetails(Models.PersonalDetailsModel submittedPersonalDetails)
        {
            //Check if a Submission has already been done
            if (SessionIsComplete())
            {
                return(View("SubmissionCompleted"));
            }

            //Check if current Post details are valid.
            if (submittedPersonalDetails != null && this.ModelState.IsValid)
            {
                //Add the current PersonalDetails to the session.
                Session.Add(cPersonalDetails, submittedPersonalDetails);

                //Redirect users that have completed the form to "CoverDetails"
                return(RedirectToAction("CoverDetails"));
            }

            return(View(submittedPersonalDetails));
        }