protected void btnModifyPosition_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } Position newPosition = new Position(); if (currentPositionID.HasValue) { newPosition = currentPosition; } //Set the posted date to now newPosition.DatePosted = DateTime.Now; newPosition.Deadline = DateTime.Parse(txtDeadline.Text); newPosition.PositionTitle = txtPositionTitle.Text; newPosition.PositionNumber = txtPositionNumber.Text; newPosition.HRRep = string.IsNullOrEmpty(txtHRRep.Text) ? null : txtHRRep.Text; newPosition.HRPhone = string.IsNullOrEmpty(txtHRPhone.Text) ? null : txtHRPhone.Text; newPosition.HREmail = string.IsNullOrEmpty(txtHREmail.Text) ? null : txtHREmail.Text; if (!updatePrimaryDepartmentStatus()) { lblPrimaryDeptErrorMessage.Text = "You must select exactly one primary department for this position"; return; } addDepartmentsToPosition(newPosition); addFileTypesToPosition(newPosition); addStepsToPosition(newPosition); newPosition.ShortDescription = txtShortDescription.Text; if (newPosition.ReferenceTemplate == null) { newPosition.ReferenceTemplate = new Template(); } newPosition.ReferenceTemplate.TemplateType = ReferenceTemplateType; newPosition.ReferenceTemplate.TemplateText = txtReferenceTemplate.Text; newPosition.NumPublications = int.Parse(txtPublications.Text); newPosition.NumReferences = int.Parse(txtReferences.Text); newPosition.AllowApps = chkAllowApplications.Checked; newPosition.FacultyView = chkAllowFaculty.Checked; newPosition.Closed = chkPositionClosed.Checked; // Only try modifying the position descriptions if an upload file exists (should be a new position only). if (filePositionDescription.HasFile) { File jobDescriptionFile = null; using (var ts = new TransactionScope()) { jobDescriptionFile = FileBLL.SavePDF(filePositionDescription, JobDescriptionFileType); ts.CommitTransaction(); } if (jobDescriptionFile == null) { //Error message: Job Description Must Be a PDF File lblInvalidFileType.Text = " *Job Description Must Be a PDF File"; return; } else { newPosition.DescriptionFile = jobDescriptionFile; } } // Only try modifying the search plans if an upload file exists (new or legacy positions). if (fileSearchPlan.HasFile) { File searchPlanFile; using (var ts = new TransactionScope()) { searchPlanFile = FileBLL.SavePDF(fileSearchPlan, SearchPlanFileType); ts.CommitTransaction(); } if (searchPlanFile == null) { //Error: Job description must be a PDF file lblInvalidSearchPlanFileType.Text = "*Search Plan Must Be A PDF File"; return; } else { newPosition.SearchPlanFile = searchPlanFile; } } if (newPosition.IsTransient()) { //Since the position is new, send an email to the AppMailTo about the new pending position PositionBLL.SendNotificationEmail(newPosition, PendingPageURL); } using (var ts = new TransactionScope()) { PositionBLL.EnsurePersistent(newPosition); ts.CommitTransaction(); } //Redirect to the position modified page Response.Redirect("PositionModified.aspx"); }