protected void btnEditProfile_Click(object sender, EventArgs e) { string username = Session["Username"].ToString(); UserService.UserService proxy = new UserService.UserService(); UserService.User user = proxy.GetUser(username); string[] questions = user.SecretQuestions.Split(','); string[] answers = user.SecretAnswers.Split(','); txtUsername.Text = user.Username; txtFirstName.Text = user.FirstName; txtLastName.Text = user.LastName; txtHomeAddress.Text = user.HomeAddress; txtBillingAddress.Text = user.BillingAddress; txtImage.Text = user.ProfileImage; txtPhone.Text = user.Phone; txtSecurity1.Text = answers[0]; txtSecurity2.Text = answers[1]; txtSecurity3.Text = answers[2]; ddlSecurity1.SelectedValue = questions[0]; ddlSecurity2.SelectedValue = questions[1]; ddlSecurity3.SelectedValue = questions[2]; divMyProfile.Visible = false; divUpdateProfile.Visible = true; divPostContainer.Visible = false; }
protected void lnkForgotPassword_Click(object sender, EventArgs e) { string username = txtLogUsername.Text; if (username == "") { smlLogUsernameHelp.InnerText = "Enter your username to retrieve password"; return; } else { smlLogUsernameHelp.InnerText = ""; } UserService.UserService proxy = new UserService.UserService(); bool verify = proxy.ValidateUsername(username); if (verify) { smlLogUsernameHelp.InnerText = "Username is not registered"; return; } UserService.User serviceUser = proxy.GetUser(username); User recoverUser = new User(serviceUser.Username, serviceUser.FirstName, serviceUser.LastName, serviceUser.Password, serviceUser.ProfileImage, serviceUser.HomeAddress, serviceUser.BillingAddress, serviceUser.EmailAddress, serviceUser.Phone, serviceUser.SecretQuestions, serviceUser.SecretAnswers, serviceUser.Verified); int arrayIndex; int secretQuestion = recoverUser.GetRandomQuestion(out arrayIndex); lblPasswordSecretQuestion.InnerText = securityQuestions[secretQuestion]; Session["UsernameRetrieve"] = username; Session["RetrievedPassword"] = recoverUser.Password; Session["SecretAnswer"] = recoverUser.GetSecretAnswer(arrayIndex); divLogin.Visible = false; divForgotPassword.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { if (Session["Username"] == null && Session["Guest"] == null) { Response.Redirect("Login.aspx"); } if (Session["Guest"] != null) { Response.Redirect("Home.aspx"); } if (Session["Username"] != null) { string username = Session["Username"].ToString(); UserService.UserService proxy = new UserService.UserService(); bool verified = proxy.IsUserVerified(username); if (!verified) { Response.Redirect("Verification.aspx?mail=false"); } } if (!IsPostBack) { string username = Session["Username"].ToString(); UserService.UserService proxy = new UserService.UserService(); UserService.User proxyUser = proxy.GetUser(username); User user = new User(proxyUser.Username, proxyUser.FirstName, proxyUser.LastName, proxyUser.Password, proxyUser.ProfileImage, proxyUser.HomeAddress, proxyUser.BillingAddress, proxyUser.EmailAddress, proxyUser.Phone, proxyUser.SecretQuestions, proxyUser.SecretAnswers, proxyUser.Verified); imgProfileImage.ImageUrl = user.ProfileImage; lblUsername.InnerText = user.Username; lblFirstName.InnerText = user.FirstName; lblLastName.InnerText = user.LastName; lblEmail.InnerText = user.EmailAddress; lblPhone.InnerText = user.Phone; lblHomeAddress.InnerText = user.HomeAddress; lblBillingAddress.InnerText = user.BillingAddress; string[] questions = user.SecretQuestions.Split(','); lblSecurityQuestion1.InnerText = securityQuestions[Int32.Parse(questions[0])]; lblSecurityQuestion2.InnerText = securityQuestions[Int32.Parse(questions[1])]; lblSecurityQuestion3.InnerText = securityQuestions[Int32.Parse(questions[2])]; // Getting Posts string url = "https://localhost:44312/api/User/GetUserPosts/" + username; WebRequest request = WebRequest.Create(url); WebResponse response = request.GetResponse(); Stream stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); String data = reader.ReadToEnd(); JavaScriptSerializer js = new JavaScriptSerializer(); List <Post> posts = js.Deserialize <List <Post> >(data); RepeaterPosts.DataSource = posts; RepeaterPosts.DataBind(); if (posts.Count == 0) { h5NoPosts.Visible = true; } stream.Close(); reader.Close(); // Getting Follow count string url2 = "https://localhost:44312/api/Follow/GetFollowCount/" + username; WebRequest request2 = WebRequest.Create(url2); WebResponse response2 = request2.GetResponse(); Stream stream2 = response2.GetResponseStream(); StreamReader reader2 = new StreamReader(stream2); String data2 = reader2.ReadToEnd(); btnFollowing.Text = "Following " + data2; stream2.Close(); reader2.Close(); // Getting Follower count string url3 = "https://localhost:44312/api/Follow/GetFollowerCount/" + username; WebRequest request3 = WebRequest.Create(url3); WebResponse response3 = request3.GetResponse(); Stream stream3 = response3.GetResponseStream(); StreamReader reader3 = new StreamReader(stream3); String data3 = reader3.ReadToEnd(); btnFollowers.Text = data3 + " Followers"; stream3.Close(); reader3.Close(); } SetupPostCardEvents(); }