Exemplo n.º 1
0
 /// <summary>
 /// Determines what happens when the <see cref="NextActionButton"/> is clicked (or whether it can be clicked)
 /// </summary>
 private void SetNextAction()
 {
     if (Engage.Utility.IsLoggedIn || !this.RequireRegistration)
     {
         if (this.JobId != null)
         {
             if (Engage.Utility.IsLoggedIn && JobApplication.HasAppliedForJob(this.JobId.Value, this.UserId))
             {
                 this.NextActionButton.Text    = this.Localize("AlreadyApplied");
                 this.NextActionButton.Enabled = false;
             }
             else if (this.CurrentJob.IsFilled)
             {
                 this.NextActionButton.Text    = this.Localize("JobIsFilled");
                 this.NextActionButton.Enabled = false;
             }
             else if (Engage.Utility.IsLoggedIn && !Engage.Utility.ValidateEmailAddress(this.UserInfo.Email))
             {
                 this.EmailErrorLabel.Visible  = true;
                 this.NextActionButton.Enabled = false;
             }
             else if (!string.IsNullOrEmpty(this.CurrentJob.ApplicationUrl))
             {
                 this.NextActionButton.Text   = this.Localize("RemoteApply");
                 this.NextActionButton.Click += this.NextActionButtonRedirect_Click;
             }
             else
             {
                 this.NextActionButton.Text   = this.Localize("Apply");
                 this.NextActionButton.Click += this.NextActionButtonApply_Click;
             }
         }
     }
     else
     {
         this.NextActionButton.Text   = this.Localize("Register");
         this.NextActionButton.Click += this.NextActionButtonLogOn_Click;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the <see cref="LinkButton.Click"/> event of the <see cref="ApplyButton"/> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void ApplyButton_Click(object sender, EventArgs e)
        {
            this.InitializeApplicantInfoSection();

            this.Page.Validate("apply");
            if (!this.Page.IsValid)
            {
                return;
            }

            var isNewApplication = this.JobApplication == null;

            if (this.JobId != null && (this.UserId == -1 || (!isNewApplication && this.JobApplication.UserId == this.UserId) || !JobApplication.HasAppliedForJob(this.JobId.Value, this.UserId)))
            {
                string resumeFileName    = string.Empty;
                string resumeContentType = string.Empty;
                if (this.ResumeUpload.PostedFile != null)
                {
                    resumeFileName    = Path.GetFileName(this.ResumeUpload.PostedFile.FileName);
                    resumeContentType = this.ResumeUpload.PostedFile.ContentType;
                }

                string coverLetterFileName    = string.Empty;
                string coverLetterContentType = string.Empty;
                if (this.CoverLetterUpload.PostedFile != null)
                {
                    coverLetterFileName    = Path.GetFileName(this.CoverLetterUpload.PostedFile.FileName);
                    coverLetterContentType = this.CoverLetterUpload.PostedFile.ContentType;
                }

                int?leadId = null;
                int value;
                if (int.TryParse(this.LeadDropDownList.SelectedValue, NumberStyles.Integer, CultureInfo.InvariantCulture, out value))
                {
                    leadId = value;
                }

                int?userId           = (this.UserId == -1) ? (int?)null : this.UserId;
                var resumeBytes      = this.ResumeUpload.FileBytes;
                var coverLetterBytes = this.CoverLetterUpload.FileBytes;
                var documentIds      = isNewApplication
                                   ? JobApplication.Apply(
                    this.JobId.Value,
                    userId,
                    resumeFileName,
                    resumeContentType,
                    resumeBytes,
                    coverLetterFileName,
                    coverLetterContentType,
                    coverLetterBytes,
                    GetTextIfVisible(this.SalaryTextBox),
                    GetTextIfVisible(this.ApplicationMessageTextBox),
                    GetTextIfVisible(this.ApplicantNameTextBox),
                    GetTextIfVisible(this.ApplicantEmailTextBox),
                    GetTextIfVisible(this.ApplicantPhoneTextBox),
                    leadId)
                                   : JobApplication.UpdateApplication(
                    this.ApplicationId.Value,
                    userId,
                    resumeFileName,
                    resumeContentType,
                    resumeBytes,
                    coverLetterFileName,
                    coverLetterContentType,
                    coverLetterBytes,
                    GetTextIfVisible(this.SalaryTextBox),
                    GetTextIfVisible(this.ApplicationMessageTextBox),
                    GetTextIfVisible(this.ApplicantNameTextBox),
                    GetTextIfVisible(this.ApplicantEmailTextBox),
                    GetTextIfVisible(this.ApplicantPhoneTextBox),
                    leadId);

                Debug.Assert(this.CurrentJob != null, "this.CurrentJob must not be null when sending notification about a new application");
                string notificationEmailAddress = Engage.Utility.HasValue(this.CurrentJob.NotificationEmailAddress)
                                                      ? this.CurrentJob.NotificationEmailAddress
                                                      : this.DefaultNotificationEmailAddresses;

                this.SendNotificationEmail(
                    GetDocument(documentIds.First, DocumentType.Resume, resumeFileName, resumeContentType, resumeBytes),
                    GetDocument(documentIds.Second, DocumentType.CoverLetter, coverLetterFileName, coverLetterContentType, coverLetterBytes),
                    isNewApplication,
                    notificationEmailAddress,
                    true,
                    "ApplicationSubject",
                    "AnonymousApplicationSubject",
                    "ApplicationUpdateSubject",
                    "NotificationEmailBody.Format");

                var applicantEmail = this.GetTextWithFallback(this.ApplicantEmailTextBox, this.UserInfo.Email);
                if (applicantEmail != null)
                {
                    this.SendNotificationEmail(
                        documentIds.First,
                        isNewApplication,
                        applicantEmail,
                        false,
                        "ApplicationAutoRespondSubject",
                        "ApplicationUpdateAutoRespondSubject",
                        "ReceiptEmailBody.Format");
                }
            }

            this.SuccessLabel.Visible         = true;
            this.SuccessLabel.Text            = this.Localize("ApplicationSent");
            this.ApplicantInfoSection.Visible = false;
        }