protected void ibtnPublicationsRemoveFile_Click(object sender, EventArgs e) { int FileID = 0; bool success = false; success = int.TryParse(((ImageButton)sender).CommandArgument, out FileID); if (success) { File fileToDelete = FileBLL.GetByID(FileID); using (var ts = new TransactionScope()) { FileBLL.DeletePDF(fileToDelete); //Update the current application Application application = selectedApplication; application.Files.Remove(fileToDelete); ApplicationBLL.EnsurePersistent(application); ts.CommitTransaction(); } } rptPublications.DataSource = GetFilesOfType(STR_Publication); rptPublications.DataBind(); }
public override void LoadData() { base.LoadData(); //Add some applications Profile profile = ProfileBLL.GetByID(StaticProperties.ExistingProfileID); Application application = new Application(); application.AppliedPosition = PositionBLL.GetByID(StaticProperties.ExistingPositionID); application.AssociatedProfile = profile; application.Email = StaticProperties.ExistingApplicantEmail; application.LastUpdated = DateTime.Now; profile.Applications = new List <Application> { application }; using (var ts = new TransactionScope()) { ApplicationBLL.EnsurePersistent(application); ProfileBLL.EnsurePersistent(profile); ts.CommitTransaction(); } }
private void UploadPublications() { FileType publicationsFileType = FileTypeBLL.GetByName(STR_Publication); Application application = selectedApplication; File file = FileBLL.SavePDF(fileUpload, publicationsFileType); using (var ts = new TransactionScope()) { if (file != null) { application.Files.Add(file); ApplicationBLL.EnsurePersistent(application); lblStatus.Text = "File Uploaded Successfully"; } else { lblStatus.Text = "File Upload Did Not Succeed: Ensure That File Is A PDF File"; } ts.CommitTransaction(); } rptPublications.DataSource = GetFilesOfType(STR_Publication); rptPublications.DataBind(); }
private void UploadFiles() { FileType selectedFileType = FileTypeBLL.GetByID(int.Parse(dlistFileTypes.SelectedValue)); //For all fileTypes except for Publications we should remove existing files if (selectedFileType.FileTypeName != STR_Publication && selectedFileType.FileTypeName != STR_LetterOfRec) { RemoveAllFilesOfType(selectedFileType.FileTypeName); } File file = FileBLL.SavePDF(fileUpload, selectedFileType); using (var ts = new TransactionScope()) { if (file != null) { Application application = selectedApplication; application.Files.Add(file); ApplicationBLL.EnsurePersistent(application); lblStatus.Text = "File Uploaded Successfully"; } else { lblStatus.Text = "File Upload Did Not Succeed: Ensure That File Is A PDF File"; } ts.CommitTransaction(); } }
/// <summary> /// Creates an application on behalf of the currently logged in user, then /// redirects to that application /// </summary> /// <remarks>Checks to make sure the logged in user has an applicant account</remarks> protected void btnPositionApply_Click(object sender, EventArgs e) { Applicant loggedInUser = ApplicantBLL.GetCurrent(); //Make sure the loggedInUser has an Applicant account if (loggedInUser == null) { Trace.Warn("Not Logged Is As Member"); FormsAuthentication.SignOut(); //Causes the user to sign out and redirect FormsAuthentication.RedirectToLoginPage(Request.Url.AbsolutePath); //Make the user log in return; } //If the applicant already has an application for this position, redirect to the app page foreach (Application app in loggedInUser.MainProfile.Applications) { if (app.AppliedPosition == currentPosition) { Response.Redirect(string.Format("{0}?ApplicationID={1}", "Applicant/App.aspx", app.ID)); } } //Now we have a valid applicant, so create the application Application newApplication = new Application(); newApplication.AppliedPosition = currentPosition; newApplication.AssociatedProfile = loggedInUser.MainProfile; newApplication.Email = loggedInUser.Email; newApplication.LastUpdated = DateTime.Now; using (var ts = new TransactionScope()) { //Now save the new application get get back the ID ApplicationBLL.EnsurePersistent(newApplication); ts.CommitTransaction(); } //Redirect to the newly created application Response.Redirect(string.Format("{0}?ApplicationID={1}", "Applicant/App.aspx", newApplication.ID.ToString())); }
protected void btnUpdateList_Click(object sender, EventArgs e) { using (var ts = new TransactionScope()) { foreach (var row in lviewApplications.Items) { int applicationID = (int)lviewApplications.DataKeys[row.DataItemIndex]["id"]; Application app = ApplicationBLL.GetByID(applicationID); app.InterviewList = ((CheckBox)row.FindControl("chkShortList")).Checked; app.GetReferences = ((CheckBox)row.FindControl("chkReferences")).Checked; app.NoConsideration = ((CheckBox)row.FindControl("chkNoConsideration")).Checked; ApplicationBLL.EnsurePersistent(app); } ts.CommitTransaction(); } lblResult.Text = "Application List Updated"; lviewReferencesToBeNotified.DataBind(); }
/// <summary> /// Removes all files of the given type from the current applicaiton. This removes the files themselves, /// the file info entry and the application files link /// </summary> private void RemoveAllFilesOfType(string fileTypeName) { List <File> existingFiles = GetFilesOfType(fileTypeName); Application application = selectedApplication; if (existingFiles.Count != 0) { using (var ts = new TransactionScope()) { foreach (File existingFile in existingFiles) { application.Files.Remove(existingFile); FileBLL.DeletePDF(existingFile); } ApplicationBLL.EnsurePersistent(application); ts.CommitTransaction(); } } }
public override void LoadData() { base.LoadData(); var application = ApplicationBLL.GetByID(StaticProperties.ExistingApplicationID); //Add some applications info CurrentPosition currentPosition = new CurrentPosition { Address1 = StaticProperties.TestString, City = StaticProperties.TestString, Country = StaticProperties.TestString, Department = StaticProperties.TestString, Institution = StaticProperties.TestString, Title = StaticProperties.TestString, Zip = StaticProperties.TestString, State = StaticProperties.TestString, ApplicationStepType = ApplicationStepType.CurrentPosition, AssociatedApplication = application }; Education education = new Education { ApplicationStepType = ApplicationStepType.Education, AssociatedApplication = application, Date = DateTime.Now, Discipline = StaticProperties.TestString, Institution = StaticProperties.TestString }; Reference reference = new Reference { AssociatedApplication = application }; Survey survey = new Survey { AssociatedApplication = application, Other = StaticProperties.TestString }; File file = new File { FileName = StaticProperties.TestString, }; FileType fileType = new FileType { ApplicationFile = true, FileTypeName = StaticProperties.TestString }; file.FileType = fileType; using (var ts = new TransactionScope()) { FileTypeBLL.EnsurePersistent(fileType); FileBLL.EnsurePersistent(file); application.CurrentPositions = new List <CurrentPosition> { currentPosition }; application.Education = new List <Education> { education }; application.References = new List <Reference> { reference }; application.Surveys = new List <Survey> { survey }; application.Files = new List <File> { file }; ApplicationBLL.EnsurePersistent(application); ts.CommitTransaction(); } }