protected void Page_Load(object sender, EventArgs e) { int jobId = Convert.ToInt32(Request.QueryString.Get("JobId")); if (jobId < 1) { Response.Redirect("~/"); } using (skillsforhireEntities db = new skillsforhireEntities()) { var titleName = (from c in db.jobprofiles where c.idJobProfile == jobId select c).FirstOrDefault(); if (titleName != null) { Page.Title = titleName.JobTitle; } else { Response.Redirect("~/Errors/OtherErrors.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { int candId = Convert.ToInt32(Request.QueryString.Get("CandId")); if (candId < 1) { Response.Redirect("~/"); } using (skillsforhireEntities db = new skillsforhireEntities()) { var myCand = (from k in db.indprofiles where k.idIndProfile == candId select k).FirstOrDefault(); if (myCand != null) { Page.Title = myCand.FullName + ": " + myCand.skill.SkillType; } else { Response.Redirect("~/Errors/OtherErrors.aspx"); } } }
protected void btnPost_Click(object sender, EventArgs e) { if (Page.IsValid) { using (skillsforhireEntities myEntities = new skillsforhireEntities()) { jobprofile myJobProfile; if (_id == -1) //Create new profile { myJobProfile = new jobprofile(); myJobProfile.CreatedBy = User.Identity.Name; myJobProfile.DateCreated = DateTime.Now; myJobProfile.LastModified = myJobProfile.DateCreated; myJobProfile.LastModifiedBy = User.Identity.Name; myEntities.jobprofiles.Add(myJobProfile); } else { myJobProfile = (from P in myEntities.jobprofiles where P.idJobProfile == _id select P).Single(); myJobProfile.LastModified = DateTime.Now; myJobProfile.LastModifiedBy = User.Identity.Name; } //Job Status myJobProfile.JobStatusId = Convert.ToInt32(ddlJobStatus.SelectedValue); //Start Time myJobProfile.StartTimeId = Convert.ToInt32(ddlStartTime.SelectedValue); //Job loc. state myJobProfile.JobLocationStateId = Convert.ToInt32(ddlJobLocState.SelectedValue); //Job loc. LG myJobProfile.JobLocationLGId = Convert.ToInt32(ddlJobLocLG.SelectedValue); //Job loc. town if (tbxJobLocTown.Text != "") { myJobProfile.JobLocationTown = tbxJobLocTown.Text; } else { myJobProfile.JobLocationTown = "-"; } //Job title myJobProfile.JobTitle = tbxJobTitle.Text; //Job description myJobProfile.JobDescription = tbxJobDescription.Text; //Profession myJobProfile.SkillId = Convert.ToInt32(ddlSkill.SelectedValue); //Specialisation if (tbxSkillSpecific.Text != "") { myJobProfile.SpecificSkill = tbxSkillSpecific.Text; } else { myJobProfile.SpecificSkill = "-"; } //Budget myJobProfile.BudgetId = Convert.ToInt32(ddlBudget.SelectedValue); //Full Name myJobProfile.ContactFullName = tbxFullName.Text; //Contact Number myJobProfile.ContactNumber = tbxContactNumb.Text; //Email myJobProfile.ContactEmail = tbxEmail.Text; //Publicise myJobProfile.Publicise = Convert.ToBoolean(cbxPublicise.Checked); //Expiry Date myJobProfile.ExpiryDate = DateTime.Today.AddDays(Convert.ToDouble(ddlAdvertDuration.SelectedValue)); //save changes myEntities.SaveChanges(); Response.Redirect("~/"); } } }
int _id = -1; //to distinguish between a new and existing post protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.QueryString.Get("JobId"))) { _id = Convert.ToInt32(Request.QueryString.Get("JobId")); } if (!Page.IsPostBack && _id > -1)//edit { ltlNew.Visible = false; ltlEdit.Text = "Edit Job Advert"; using (skillsforhireEntities myEntities = new skillsforhireEntities()) { var jobAd = (from j in myEntities.jobprofiles where j.idJobProfile == _id select j).SingleOrDefault(); if (jobAd.CreatedBy == User.Identity.Name) { //Get job status ddlJobStatus.DataBind(); ListItem myddlJobStatus = ddlJobStatus.Items.FindByValue(jobAd.JobStatusId.ToString()); if (myddlJobStatus != null) { myddlJobStatus.Selected = true; } //Start Time ddlStartTime.DataBind(); ListItem myddlStartTime = ddlStartTime.Items.FindByValue(jobAd.StartTimeId.ToString()); if (myddlStartTime != null) { myddlStartTime.Selected = true; } //Job loc. state ddlJobLocState.DataBind(); ListItem myddlState = ddlJobLocState.Items.FindByValue(jobAd.JobLocationStateId.ToString()); if (myddlState != null) { myddlState.Selected = true; } //Job loc. LG ddlJobLocLG.DataBind(); ListItem myddlLG = ddlJobLocLG.Items.FindByValue(jobAd.JobLocationLGId.ToString()); if (myddlLG != null) { myddlLG.Selected = true; } //Job loc. town tbxJobLocTown.Text = jobAd.JobLocationTown.ToString(); //Job title tbxJobTitle.Text = jobAd.JobTitle.ToString(); //Job description tbxJobDescription.Text = jobAd.JobDescription; //Profession ddlSkill.DataBind(); ListItem myddlSkill = ddlSkill.Items.FindByValue(jobAd.SkillId.ToString()); if (myddlSkill != null) { myddlSkill.Selected = true; } //Specialisation tbxSkillSpecific.Text = jobAd.SpecificSkill.ToString(); //Budget ddlBudget.DataBind(); ListItem myddlBudget = ddlBudget.Items.FindByValue(jobAd.BudgetId.ToString()); if (myddlBudget != null) { myddlBudget.Selected = true; } //Full Name tbxFullName.Text = jobAd.ContactFullName; //Contact Number tbxContactNumb.Text = jobAd.ContactNumber; //Email tbxEmail.Text = jobAd.ContactEmail; //Expiry Date //Publicise cbxPublicise.Checked = Convert.ToBoolean(jobAd.Publicise); } } } }
protected void btnAccDelConfirmation_Click(object sender, EventArgs e) { string userAccName = User.Identity.Name.ToString(); MembershipUser user = Membership.GetUser(userAccName); //clean-up profile using (skillsforhireEntities myObjects = new skillsforhireEntities()) { var ind = (from i in myObjects.indprofiles where i.UserName == userAccName select i).Single(); if (ind != null) { myObjects.indprofiles.Remove(ind); } myObjects.SaveChanges(); } //clean-up posted jobs using (skillsforhireEntities myEntities = new skillsforhireEntities()) { var jobPosts = from p in myEntities.jobprofiles where p.CreatedBy == userAccName select p; if (jobPosts != null) { foreach (var jPost in jobPosts) { myEntities.jobprofiles.Remove(jPost); } myEntities.SaveChanges(); } } //update deletedMembership table using (skillsforhireEntities myContext = new skillsforhireEntities()) { deletedmembership delMemb = new deletedmembership(); delMemb.userName = user.UserName; delMemb.email = user.Email; delMemb.leavingReason = tbxAccDelReason.Text; delMemb.Date = DateTime.Now; //Save to database myContext.deletedmemberships.Add(delMemb); myContext.SaveChanges(); } //send confirmation email string fileName = Server.MapPath("~/App_Data/AccountDeleteConfirmation.txt"); string mailBody = File.ReadAllText(fileName); mailBody = mailBody.Replace("##UserName##", user.UserName); MailMessage myMessage = new MailMessage(); myMessage.Subject = "Your www.skills4hire.com.ng Account is Deleted"; myMessage.Body = mailBody; myMessage.From = new MailAddress(AppConfiguration.FromAccAddress, "Accounts"); myMessage.To.Add(new MailAddress(user.Email)); SmtpClient mySmtpClient = new SmtpClient(); mySmtpClient.Send(myMessage); //Delete account Membership.DeleteUser(userAccName); //programatically logout acccount and redirect to homepage FormsAuthentication.SignOut(); Response.Redirect("~/"); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //Load candidate profile information string userName = User.Identity.Name; using (skillsforhireEntities myEntities = new skillsforhireEntities()) { var pullProfile = (from p in myEntities.indprofiles where p.UserName == userName select p).Single(); //Gold Membership ltlGoldMembership.Text = pullProfile.GoldSubExpire.ToString(); //full name tbxFullName.Text = pullProfile.FullName; //gender ddlGender.DataBind(); ListItem myddlGender = ddlGender.Items.FindByValue(pullProfile.GenderId.ToString()); if (myddlGender != null) { myddlGender.Selected = true; } //Contact Number tbxContactNumb.Text = pullProfile.ContactNo; //email tbxEmail.Text = pullProfile.EmailAddr; //state ddlState.DataBind(); ListItem myddlState = ddlState.Items.FindByValue(pullProfile.StateId.ToString()); if (myddlState != null) { myddlState.Selected = true; } //local govt ddlLocalGovt.DataBind(); ListItem myddlLocalGovt = ddlLocalGovt.Items.FindByValue(pullProfile.LocalGovtId.ToString()); if (myddlLocalGovt != null) { myddlLocalGovt.Selected = true; } //town tbxTown.Text = pullProfile.Town; //Profession ddlProfession.DataBind(); ListItem myddlProfession = ddlProfession.Items.FindByValue(pullProfile.SkillsId.ToString()); if (myddlProfession != null) { myddlProfession.Selected = true; } //Professional speciality tbxSpeciality.Text = pullProfile.SkillsSpecific; //job experience tbxExperience.Text = pullProfile.JobExperience; //qualifications tbxQualification.Text = pullProfile.Qualification; //note tbxNote.Text = pullProfile.Note; //publish cbxPublish.Checked = Convert.ToBoolean(pullProfile.Publish); } } }