using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CareersOnlineLibrary; using CareersOnlineLibrary.Entity; using CareersOnlineLibrary.Controller; namespace WebApplication1.Account { public partial class UpdateProfileDetails : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { InitialisePage(); } } private void InitialisePage() { CareersOnlineController controller = new CareersOnlineController(); //let's get the user profile TRAProfile profile; profile = controller.GetTRAProfileByProfileID(int.Parse(Session["UserID"].ToString())); NameIDEntityCollection gender = new NameIDEntityCollection(); NameIDEntityCollection location = new NameIDEntityCollection(); gender = controller.GetGender(); location = controller.GetCountries(); Gender.DataSource = gender; Gender.DataBind(); Location.DataSource = location; Location.DataBind(); if (profile != null) { FirstName.Text = profile.FirstName; LastName.Text = profile.LastName; Gender.SelectedIndex = Gender.Items.IndexOf(Gender.Items.FindByText(profile.Gender)); Location.SelectedIndex = Location.Items.IndexOf(Location.Items.FindByText(profile.Country)); Email.Text = profile.Email; PhoneNumber.Text = profile.ContactNumber; } controller = null; profile = null; } protected void CancelUserButton_Click(object sender, EventArgs e) { Response.Redirect("~/Default.aspx"); } protected void UpdateUserButton_Click(object sender, EventArgs e) { CareersOnlineController controller = new CareersOnlineController(); TRAProfile profile; profile = controller.GetTRAProfileByProfileID(int.Parse(Session["UserID"].ToString())); profile.FirstName = FirstName.Text; profile.LastName = LastName.Text; profile.Gender = Gender.SelectedItem.Text; profile.Country = Location.SelectedItem.Text; profile.Email = Email.Text; profile.ContactNumber = PhoneNumber.Text; controller.UpdateJobSeekerProfile(profile); //show confimation pop up and redirect to home page string message = "User profile was updated successfully."; string HomePage = Request.Url.ToString(); HomePage = HomePage.Replace("/Account/UpdateProfileDetails.aspx", "/Default.aspx"); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(""); ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); controller = null; profile = null; } } }