public void PopulateGridView_Jobapplicants() { List<JobApplication> ListOfJobApplicants = new List<JobApplication>(); BLL.BLLRecruiterWebsiteManager GetListOfJobApplicant = new BLL.BLLRecruiterWebsiteManager(); ListOfJobApplicants = GetListOfJobApplicant.GetListOfAllActiveJobApplicant(); GridOfJobApplicants.DataSource = from x in ListOfJobApplicants select new { x.EmpidApplied, x.JobIdApplied, x.FullName, x.ContactNumber, x.Email, x.CoverLetter, x.UploadCvPath, }; GridOfJobApplicants.DataBind(); }
protected void btnSubmit_Click(object sender, EventArgs e) { string username = txtUsername.Text; string code = txtCode.Text; Employer emp = null; try { BLLRecruiterWebsiteManager BLLMngr = new BLLRecruiterWebsiteManager(); List<Employer> empList = BLLMngr.ListOfEmployers(); foreach(Employer ee in empList) { if(ee.EmployerUsername == username) { emp = ee; } } if(emp != null) { if(emp.EmployerActivationKey == code) { emp.EmployerAccountActive = true; bool result = BLLMngr.ActivateEmpProfile(emp); if(result == true) { Response.Redirect("~/EmployerProfile.aspx"); } } } } catch(Exception ex) { throw; } }
/* populates */ public void PopulateGridView_Job() { /* get list of all active jobs. */ List<Job> ListOfAllActiveJobs = new List<Job>(); BLL.BLLRecruiterWebsiteManager GetListOfAllActiveJobs = new BLLRecruiterWebsiteManager(); ListOfAllActiveJobs = GetListOfAllActiveJobs.GetListOfAllActiveJobs(); GridView1.DataSource = from t in ListOfAllActiveJobs orderby t.DateCreated ascending select new { t.JobID, t.EmpID, t.Category, t.Company, t.Title, t.Location, t.Requirements, t.Type, t.Terms, t.Salary, t.DateCreated, }; GridView1.DataBind(); }
// method to send account activation mail // see description of same method in the code behind // the employer sign up page public void SendActivationMail(string jsEmail, string username, string jsActivationCode) { BLLRecruiterWebsiteManager BLLMngr = new BLLRecruiterWebsiteManager(); List<AdminObj> adminList = BLLMngr.GetListOfAllActiveAdminUsers(); AdminObj admin = null; string adminEmail = "*****@*****.**"; foreach (AdminObj a in adminList) { if (a.Email == adminEmail) { admin = a; } } string decryptedPwd = Crypto.DecryptStringAES(admin.EmailHash, admin.SecretCode); using (MailMessage mm = new MailMessage(admin.Email, jsEmail)) { mm.Subject = "Account Activation"; string body = "Hello " + username + ","; body += "<br /><br />This is your account activation code:"; body += "<br />" + jsActivationCode; body += "<br /><br />Thanks<br />The Recruitment Group"; mm.Body = body; mm.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(admin.Email, decryptedPwd); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mm); } }
protected void btnAdminLogin_Click(object sender, EventArgs e) { string AdminUsername = txtAdminUsername.Text; string AdminPassword = txtAdminPassword.Text; AdminObj AdminObject = new AdminObj(); BLLRecruiterWebsiteManager BllManager = new BLL.BLLRecruiterWebsiteManager(); AdminObject = BllManager.GetAdminLogin(AdminUsername, AdminPassword); bool validUser = PasswordHash.ValidatePassword(AdminPassword, AdminObject.PasswordHash); if (validUser == true) { Session["AdminID"] = AdminObject.Username; Response.Redirect("~/Admin.aspx"); } try { txtAdminPassword.Text = "Incorrect Password"; } catch (Exception) { throw; } }
protected void btnCreateAdmin_Click(object sender, EventArgs e) { string Username = txtUsername.Text; string Password = txtPassword.Text; string PasswordCon = txtPasswordCon.Text; string Email = txtEmail.Text; string EmailPwd = txtEmailPwd.Text; string EmailPwdConfirm = txtEmailPwdConfirm.Text; string FavouriteAnimal = txtSecretCode.Text; if (txtPassword.Text == txtPasswordCon.Text) { // hash/ salt password string saltHashReturned = PasswordHash.CreateHash(txtPassword.Text); saltHashReturned = PasswordHash.CreateHash(txtPassword.Text); int commaIndex = saltHashReturned.IndexOf(":"); string extractedString = saltHashReturned.Substring(0, commaIndex); commaIndex = saltHashReturned.IndexOf(":"); extractedString = saltHashReturned.Substring(commaIndex + 1); commaIndex = extractedString.IndexOf(":"); string salt = extractedString.Substring(0, commaIndex); commaIndex = extractedString.IndexOf(":"); extractedString = extractedString.Substring(commaIndex + 1); string hash = extractedString; if (txtEmailPwd.Text == txtEmailPwdConfirm.Text) { // encrypt email with BLL encryption class string securedPwd = Crypto.EncryptStringAES(EmailPwd, FavouriteAnimal); AdminObj adminObj = new AdminObj(); adminObj.Username = Username; adminObj.PasswordHash = salt; adminObj.PasswordSalt = saltHashReturned; /* didn't know what you wanted me to do with that email.. so both rows in the database are email and email ahas. */ // ^^thanks this is what I was looking up for adminObj.Email = Email; adminObj.EmailHash = securedPwd; adminObj.SecretCode = FavouriteAnimal; BLLRecruiterWebsiteManager SendingAdminObjectToBLL = new BLLRecruiterWebsiteManager(); SendingAdminObjectToBLL.CreateAdminUser(adminObj); Response.Redirect("~/Admin.aspx"); } } }
protected void btnApply_Click(object sender, EventArgs e) { string fileName = Path.GetFileName(CvApply.PostedFile.FileName); string Jobid = Request.QueryString["id"]; string Empid = Request.QueryString["empId"]; int JobidParsed = int.Parse(Jobid); int EmpidParsed = int.Parse(Empid); fileName = DateTime.Now.ToString() + fileName; fileName = fileName.Replace("/", " ").Replace("'\'", "").Replace(" ", "").Replace("-", "").Replace(":", "").Replace(";", ""); CvApply.PostedFile.SaveAs(Server.MapPath("~/Uploads/") + fileName); JobApplication UserAppliedForJob = new JobApplication(); UserAppliedForJob.FullName = txtAppFullname.Text; UserAppliedForJob.ContactNumber = txtAppContactNumber.Text; Validations validations = new Validations(); UserAppliedForJob.Email = txtEmail.Text; bool isValid = validations.EmailValidation(UserAppliedForJob.Email); if (!isValid) { txtEmail.Text = "Invalid Email"; } UserAppliedForJob.Experience = txtRelvExp.Text; UserAppliedForJob.CoverLetter = txtCoverLetter.Text; UserAppliedForJob.UploadCvPath = fileName; UserAppliedForJob.JobIdApplied = JobidParsed; UserAppliedForJob.EmpidApplied = EmpidParsed; if (Session["JobseekerID"] != null) { UserAppliedForJob.JSId = (int)Session["JobseekerID"]; } else { // all guests have jobseeker id of 1 int noID = 1; UserAppliedForJob.JSId = noID; } if (isValid) { BLLRecruiterWebsiteManager ProcessJobApp = new BLLRecruiterWebsiteManager(); bool check; check = ProcessJobApp.InsertJobApplication(UserAppliedForJob); Response.Redirect("~/index.aspx"); } }
protected void btnJSLoginSubmit_Click(object sender, EventArgs e) { //JOBSEEKER LOGIN PAGE METHOD (Button click) string jsUName = txtJSUsername.Text; string jsPwd = txtJSPassword.Text; Jobseeker jseeker; BLLRecruiterWebsiteManager BLLRecWebMngr = new BLLRecruiterWebsiteManager(); try { jseeker = (BLLRecWebMngr.GetJSLogin(jsUName, jsPwd)); string JSPassword = jseeker.JobseekerSaltHashPwd; bool validUser = PasswordHash.ValidatePassword(txtJSPassword.Text, JSPassword); if (validUser == true) { Session["JobseekerID"] = jseeker.JobseekerID; if (jseeker.JobseekerAccountActive == true) { Response.Redirect("~/JobseekerProfile.aspx"); } else { Response.Redirect("~/JobseekerActivation.aspx"); } } else { Response.Write("Incorrect Password"); txtJSPassword.Text = "Incorrect Password"; } } catch (Exception ex) { throw; } }
protected void Page_Load(object sender, EventArgs e) { string Jobid = Request.QueryString["id"]; string Empid = Request.QueryString["empId"]; int JobidParsed = int.Parse(Jobid); int EmpidParsed = int.Parse(Empid); Job GotJobDetails = new Job(); BLL.BLLRecruiterWebsiteManager GettingJobDetailsMethod = new BLLRecruiterWebsiteManager(); GotJobDetails = GettingJobDetailsMethod.GetJobDetails(JobidParsed, EmpidParsed); lblGetJobTitle.Text = GotJobDetails.Title.ToString(); lblGetCompany.Text = GotJobDetails.Company.ToString(); lblGetLocation.Text = GotJobDetails.Location.ToString(); lblGetDescription.Text = GotJobDetails.Description.ToString(); lblGetJobType.Text = GotJobDetails.Type.ToString(); lblGetSalary.Text = GotJobDetails.Salary.ToString(); lblGetDataCreated.Text = GotJobDetails.DateCreated.ToString(); }
protected void Page_Load(object sender, EventArgs e) { string JobType = Request.QueryString["Type"]; string Location = Request.QueryString["loc"]; lblJobCategory.Text = JobType.ToString(); lblLocationSearch.Text = Location.ToString(); Job SearchJobRequest = new Job(); List<Job> JobList = new List<Job>(); BLLRecruiterWebsiteManager RequestJobSearch = new BLLRecruiterWebsiteManager(); JobList = RequestJobSearch.SearchJob(JobType, Location); // List<Job> EditJobList = new List<Job>(); GridView1.DataSource = from t in JobList orderby t.DateCreated ascending select new { t.JobID, t.EmpID, t.Category, t.Title, t.Company, t.Location, t.Description, t.Type, t.Terms, t.Salary, t.DateCreated }; // GridView1.DataBound(); GridView1.DataBind(); }
protected void btnSubmit_Click(object sender, EventArgs e) { string username = txtUsername.Text; string code = txtCode.Text; Jobseeker js = null; try { BLLRecruiterWebsiteManager BLLMngr = new BLLRecruiterWebsiteManager(); List<Jobseeker> JSList = BLLMngr.ListOfJobseekers(); foreach(Jobseeker j in JSList) { if(j.JobseekerUsername == username) { js = j; } } if(js != null) { if(js.JobseekerActivationKey == code) { js.JobseekerAccountActive = true; bool result = BLLMngr.ActivateJSProfile(js); if (result) { Session["JobseekerID"] = js.JobseekerID; //Response.Redirect("~/JobseekerProfile.aspx"); Response.Redirect("~/RegisterJobInterest.aspx"); } } } } catch(Exception ex) { throw; } }
protected void Page_Load(object sender, EventArgs e) { // I had to update this part with an 'if' statement to check whether the EmployerID is not null // this has to do with the login and logout functions // logging out sets the value to null meaning user can't see all active jobs if (Session["EmployerID"] != null) { DataSet dataSet = new DataSet(); /* // dataSet.ReadXml(@"C:\Users\10274298\Desktop\THIS IS THE WEBSITE//\WebAppAssignment//\RecruiterWebsite\RecruiterWebsite\XML\Jobs.xml"); */ List<Job> ListOfAllJobIndex = new List<Job>(); BLL.BLLRecruiterWebsiteManager GetListOfAllJobs = new BLL.BLLRecruiterWebsiteManager(); ListOfAllJobIndex = GetListOfAllJobs.GetListOfAllActiveJobs(); GridView1.DataSource = from x in ListOfAllJobIndex select new { x.JobID, x.EmpID, x.Category, x.Title, x.Location, x.Description, x.Type, x.Terms, x.Salary, x.DateCreated }; GridView1.DataBind(); } }
protected void btnEmpLoginSubmit_Click(object sender, EventArgs e) { /* if (txtEmpUsername.Text.Equals("admin")) { Response.Redirect("~/AdminLogin.aspx"); } else { * * */ // code for Employer Login goes here string empUName = txtEmpUsername.Text.ToString(); string empPwd = txtEmpPassword.Text.ToString(); Employer Emp; BLLRecruiterWebsiteManager BLLRecWebMngr = new BLLRecruiterWebsiteManager(); try { // the method ValidatePassword takes two parameters: // users password from login webform and the salted/hashed password from the database // the salted/hashed password is retrieved from the database via emplyer object // by calling the BLL layer method GetEmployerLogin // which takes the parameters of the username and password from the webform // and passes them on down to the DAL layer method GetEmpLogin() Emp = BLLRecWebMngr.GetEmployerLogin(empUName, empPwd); if (Emp == null) { txtEmpUsername.Text = "wrong Username/Password"; txtEmpUsername.ForeColor = System.Drawing.Color.Red; } else { bool validUser = PasswordHash.ValidatePassword(txtEmpPassword.Text, Emp.EmployerSaltHashPwd); if (validUser == true) { //string EmpID, Session["EmployerID"] = Emp.EmployerID; if (Emp.EmployerAccountActive) { Response.Redirect("~/EmployerProfile.aspx"); } else { Response.Redirect("~/EmployerActivation.aspx"); } } else { Response.Write("Incorrect Password"); txtEmpPassword.Text = "Incorrect Password"; } } } catch (Exception ex) { throw; } /* }*/ }
public void PopulateGridView_JobSeekers() { List<Jobseeker> ListOfActiveJobSeekers = new List<Jobseeker>(); BLL.BLLRecruiterWebsiteManager GetListOfActiveJobSeekers = new BLLRecruiterWebsiteManager(); ListOfActiveJobSeekers = GetListOfActiveJobSeekers.GetAllActiveJobSeekersForAdmin(); GridViewJobSeekers.DataSource = from a in ListOfActiveJobSeekers select new { a.JobseekerID, a.JobseekerUsername, a.JobseekerEmail, a.JobseekerPhone }; GridViewJobSeekers.DataBind(); }
private void PrimeSearch() { BLLRecruiterWebsiteManager BLLMngr = new BLLRecruiterWebsiteManager(); List<Job> listJob = BLLMngr.GetJobListFromDAL(); List<string> jobCategoryList = new List<string>(); List<string> jobLocationList = new List<string>(); string category = String.Empty; string location = String.Empty; foreach (Job job in listJob) { category = job.Category; jobCategoryList.Add(category); location = job.Location; jobLocationList.Add(location); } jobCategoryList = (from jc in jobCategoryList select jc).Distinct().ToList(); jobCategoryList = jobCategoryList.OrderBy(jc => jc).ToList(); jobLocationList = (from l in jobLocationList select l).Distinct().ToList(); jobLocationList = jobLocationList.OrderBy(l => l).ToList(); DropDownList2.DataSource = jobCategoryList; DropDownList2.DataBind(); DropDownList1.DataSource = jobLocationList; DropDownList1.DataBind(); drplstJobCategory.DataSource = jobCategoryList; drplstJobCategory.DataBind(); drplstLocation.DataSource = jobLocationList; drplstLocation.DataBind(); }
public void PopulateGridView_Employers() { BLL.BLLRecruiterWebsiteManager GetListOfActiveJobSeekers = new BLLRecruiterWebsiteManager(); List<Employer> ListOfAllActiveEmployers = new List<Employer>(); ListOfAllActiveEmployers = GetListOfActiveJobSeekers.GetListOfEmployerAdmin(); EmployerGridView.DataSource = from b in ListOfAllActiveEmployers select new { b.EmployerID, b.EmployerUsername, b.EmployerEmail, b.EmployerPhone }; EmployerGridView.DataBind(); }
private void CreateNewJobseekerProfile() { //JOB SEEKER SIGNUP METHOD string jsUName = txtJSSUUsername.Text.ToString(); string jsEmail = txtJSSUEmail.Text.ToString(); string jsPhone = txtJSSUPhone.Text.ToString(); string jsPassword = txtJSSUPassword.Text.ToString(); bool runValidation = RunValidation(jsUName, jsEmail, jsPhone, jsPassword); if (runValidation) { string jsActivationCode = Guid.NewGuid().ToString(); bool jsAccActive = false; if (txtJSSUPassword.Text == txtJSSUPasswordConfirm.Text) { string saltHashReturned = PasswordHash.CreateHash(txtJSSUPassword.Text); int commaIndex = saltHashReturned.IndexOf(":"); string extractedString = saltHashReturned.Substring(0, commaIndex); commaIndex = saltHashReturned.IndexOf(":"); extractedString = saltHashReturned.Substring(commaIndex + 1); commaIndex = extractedString.IndexOf(":"); string salt = extractedString.Substring(0, commaIndex); commaIndex = extractedString.IndexOf(":"); extractedString = extractedString.Substring(commaIndex + 1); string hash = extractedString; Jobseeker js = new Jobseeker(jsUName, jsEmail, jsPhone, salt, saltHashReturned, jsActivationCode, jsAccActive); BLLRecruiterWebsiteManager BLLRWebMngr = new BLLRecruiterWebsiteManager(); try { bool result = BLLRWebMngr.CreateJobSeekerProfile(js); if (result) { Session["JobseekerID"] = js.JobseekerID; SendActivationMail(jsEmail, jsUName, jsActivationCode); Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "confirm('Activation Email Sent')", true); Response.Redirect("~/JobseekerActivation.aspx"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "alert('Error: try again)", true); } } catch (Exception ex) { Response.Write(ex.Message); throw; } } else { txtJSSUPassword.Text = "Passwords don't match!"; } } }
public void CreateJob() { string jobCategory; string company; string title; string location; string description; string requirements ; string type; string terms; decimal salary; string link = string.Empty; jobCategory = drplstCreateJobCategory.SelectedItem.ToString(); company = txtCompany.Text; title = txtCreateJobTitle.Text; location = drplstCreateJobLocation.SelectedItem.ToString(); description = txtCreateJobDescription.Text; requirements = txtCreateJobRequirements.Text; type = drplstCreateJobType.SelectedItem.ToString(); terms = drplstCreateJobTerms.SelectedItem.ToString(); bool isValid = decimal.TryParse(txtCreateJobSalary.Text, out salary); if (!IsValid) { txtCreateJobSalary.Text = "Invalid entry"; } if(isValid) { Job job = new Job(jobCategory, company, title, location, description, requirements, type, terms, salary, link); job.EmpID = (int)Session["EmployerID"]; // job.Link = string.Format(("~/Job.aspx?id={0}&empId={1}"), job.JobID.ToString(), job.EmpID.ToString()); job.DateCreated = DateTime.Now; try { BLLRecruiterWebsiteManager BLLMngr = new BLLRecruiterWebsiteManager(); job.Link = string.Format(("~/Job.aspx?id={0}&empId={1}"), job.JobID.ToString(), job.EmpID.ToString()); bool result = BLLMngr.InsertJob(job); if (result == true) { job.Link = string.Format(("~/Job.aspx?id={0}&empId={1}"), job.JobID.ToString(), job.EmpID.ToString()); //NEW CODE I'VE ENTERED FOR EMAILER List<WatchedJob> watchJobList = BLLMngr.GetListOfWatchedJobsFromDAL(); List<Jobseeker> jobseekerList = BLLMngr.ListOfJobseekers(); Jobseeker getJobsseeker = null; foreach (WatchedJob wj in watchJobList) { foreach (Jobseeker j in jobseekerList) { if (j.JobseekerID == wj.JobseekerID) { getJobsseeker = j; } } if (jobCategory == "Finance") { if (wj.Finance == true) { SendNotificationOfNewJobMail(getJobsseeker.JobseekerEmail, getJobsseeker.JobseekerUsername, jobCategory, title, description); } } else if (jobCategory == "Computing") { if (wj.Computing == true) { SendNotificationOfNewJobMail(getJobsseeker.JobseekerEmail, getJobsseeker.JobseekerUsername, jobCategory, title, description); } } else if (jobCategory == "Retail") { if (wj.Retail == true) { SendNotificationOfNewJobMail(getJobsseeker.JobseekerEmail, getJobsseeker.JobseekerUsername, jobCategory, title, description); ; } } else if (jobCategory == "Sales") { if (wj.Sales == true) { SendNotificationOfNewJobMail(getJobsseeker.JobseekerEmail, getJobsseeker.JobseekerUsername, jobCategory, title, description); } } else if (jobCategory == "Engineering") { if (wj.Engineering == true) { SendNotificationOfNewJobMail(getJobsseeker.JobseekerEmail, getJobsseeker.JobseekerUsername, jobCategory, title, description); } } else if (jobCategory == "Legal") { if (wj.Legal == true) { SendNotificationOfNewJobMail(getJobsseeker.JobseekerEmail, getJobsseeker.JobseekerUsername, jobCategory, title, description); } } else if (jobCategory == "Tourism") { if (wj.Tourism == true) { SendNotificationOfNewJobMail(getJobsseeker.JobseekerEmail, getJobsseeker.JobseekerUsername, jobCategory, title, description); } } else if (jobCategory == "Publishing") { if (wj.Publishing == true) { SendNotificationOfNewJobMail(getJobsseeker.JobseekerEmail, getJobsseeker.JobseekerUsername, jobCategory, title, description); } } else if (jobCategory == "Telecoms") { if (wj.Telecoms == true) { SendNotificationOfNewJobMail(getJobsseeker.JobseekerEmail, getJobsseeker.JobseekerUsername, jobCategory, title, description); } } else if (jobCategory == "Manufacturing") { if (wj.Manufacturing == true) { SendNotificationOfNewJobMail(getJobsseeker.JobseekerEmail, getJobsseeker.JobseekerUsername, jobCategory, title, description); } } } /* Computing Retail Sales Engineering Legal Tourism Publishing Telecoms Manufacturing * */ //END OF NEW CODE DataRow row = dt.NewRow(); /* dt.Columns.Add("jobID"); dt.Columns.Add("empID"); * */ row["jobID"] = job.JobID; job.Link = string.Format(("~/JobApply.aspx?id={0}&empId={1}"), job.JobID.ToString(), job.EmpID.ToString()); row["empID"] = job.EmpID; row["jobCategory"] = job.Category; row["company"] = job.Company; row["title"] = job.Title; row["location"] = job.Location; row["description"] = job.Description; row["requirements"] = job.Requirements; row["terms"] = job.Terms; row["salary"] = job.Salary; row["link"] = job.Link; row["dateCreated"] = job.DateCreated; dt.Rows.Add(row); ds.AcceptChanges(); ds.WriteXml(Server.MapPath("~/XML/Jobs.xml")); Response.Redirect("~/JobSearch.aspx?Type=" + job.Category.ToString() + "&loc=" + job.Location.ToString() + ""); } } catch (Exception ex) { throw; } } /* Validations validate = new Validations(); string isValid = validate.ValidateXMLUsingXSD(); if(isValid == string.Empty) { }*/ }
// email notification of new job public void SendNotificationOfNewJobMail(string jsEmail, string jsUsername, string jobType, string jobTitle, string jobDescription) { BLLRecruiterWebsiteManager BLLMngr = new BLLRecruiterWebsiteManager(); List<AdminObj> adminList = BLLMngr.GetListOfAllActiveAdminUsers(); AdminObj admin = null; string adminEmail = "*****@*****.**"; foreach (AdminObj a in adminList) { if (a.Email == adminEmail) { admin = a; } } string decryptedPwd = Crypto.DecryptStringAES(admin.EmailHash, admin.SecretCode); using (MailMessage mm = new MailMessage(admin.Email, jsEmail)) { mm.Subject = "New Job You May be Interested in Available!"; string body = "Hello " + jsUsername + ","; body += "<br />Check out this new " + jobType +" job which has just been posted: "; body += "<br />Title: " + jobTitle; body += "<br />Description: " + jobDescription; body += "<br /> See Website for further details!"; mm.Body = body; mm.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(admin.Email, decryptedPwd); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mm); } }
private void CreateNewEmpProfile() { // creates strings from name, email, phone textboxes string empUName = txtEmpSUUsername.Text.ToString(); string empEmail = txtEmpSUEmail.Text.ToString(); string empPhone = txtEmpSUPhone.Text.ToString(); string empPassword = txtEmpSUPassword.Text.ToString(); bool runValidation = RunValidation(empUName, empEmail, empPhone, empPassword); if (runValidation) { string empActivationCode = Guid.NewGuid().ToString(); bool empAccActive = false; // if passwords user entered match, do the following if (txtEmpSUPassword.Text == txtEmpSUPasswordConfirm.Text) { // creates a string for salted and hashed password // password is salted and hashed using the method CreateHash() // from the PassordHash class the source code of which comes from // https://github.com/defuse/password-hashing/blob/master/compatible/PasswordHash.cs // we learned how to implement the PasswordHash class from // https://www.youtube.com/watch?v=AR7_SHnptZc string saltHashReturned = PasswordHash.CreateHash(txtEmpSUPassword.Text); // from the first colon to the second is the 'salt' // from the second colon to the end is the 'hash' saltHashReturned = PasswordHash.CreateHash(txtEmpSUPassword.Text); int commaIndex = saltHashReturned.IndexOf(":"); string extractedString = saltHashReturned.Substring(0, commaIndex); commaIndex = saltHashReturned.IndexOf(":"); extractedString = saltHashReturned.Substring(commaIndex + 1); commaIndex = extractedString.IndexOf(":"); string salt = extractedString.Substring(0, commaIndex); commaIndex = extractedString.IndexOf(":"); extractedString = extractedString.Substring(commaIndex + 1); string hash = extractedString; Employer emp = new Employer(empUName, empEmail, empPhone, salt, saltHashReturned, empActivationCode, empAccActive); // 'using BLL;' namespace creates new instance of that class // string parameters are passed in BLLRecruiterWebsiteManager BLLRWebMngr = new BLLRecruiterWebsiteManager(); try { bool result = BLLRWebMngr.CreateEmployerProfile(emp); if (result) { Session["EmployerID"] = emp.EmployerID; SendActivationMail(empEmail, empUName, empActivationCode); Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "confirm('Activation Email Sent')", true); Response.Redirect("~/EmployerActivation.aspx"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "alert('Error: try again)", true); } } catch (Exception ex) { Response.Write(ex.Message); throw; } } else { // error in the code here - neither message displaying //txtEmpSUPassword.Text = "Passwords do not match!"; txtEmpSUPassword.Text = "Passwords don't match!"; } } }
private void GetSelectedJobs() { int wjID = (int)Session["JobseekerID"]; bool finance = false; bool computing = false; bool retail = false; bool sales = false; bool engineering = false; bool legal = false; bool tourism = false; bool publishing = false; bool telecoms = false; bool manufacturing = false; if(listJobs.Items[0].Selected) { finance = true; } if (listJobs.Items[1].Selected) { computing = true; } if (listJobs.Items[2].Selected) { retail = true; } if (listJobs.Items[3].Selected) { sales = true; } if (listJobs.Items[4].Selected) { engineering = true; } if (listJobs.Items[5].Selected) { legal = true; } if (listJobs.Items[6].Selected) { tourism = true; } if (listJobs.Items[7].Selected) { publishing = true; } if (listJobs.Items[8].Selected) { telecoms = true; } if (listJobs.Items[9].Selected) { manufacturing = true; } try { WatchedJob watchedJob = new WatchedJob(wjID, finance, computing, retail, sales, engineering, legal, tourism, publishing, telecoms, manufacturing); BLLRecruiterWebsiteManager BLLMngr = new BLLRecruiterWebsiteManager(); bool result = BLLMngr.InsertWatchedJob(watchedJob); if (result == true) { Response.Redirect("~/JobseekerProfile.aspx"); } } catch(Exception ex) { throw; } }