protected void btnRegister_Click(object sender, EventArgs e) { string pass = ""; pass = txtPass.Text; string hashedPass = PassWords.HashPassword(pass); if (mycheckbox.Checked == false) // register as Guest { GuestModel _guest = new GuestModel(); Eventrix_Client.Registration reg = new Eventrix_Client.Registration(); _guest.NAME = txtName.Text; _guest.SURNAME = txtSurname.Text; _guest.EMAIL = txtEmail.Text; _guest.PASS = hashedPass; _guest.TYPE = "PUBLIC"; int response = reg.RegisterGuest(_guest); // txtName.Text = response; if (response != -1) { EmailClient emailClient = new EmailClient(); emailClient.sendMsg_SuccessRegistration(_guest); if (profilePic.HasFile) { makeDirectory(response); ImageFile mainPic = new ImageFile(); mainPic = UploadFile(profilePic, response, SUBFOLDER); string res = svcClient.saveImage(mainPic); } Response.Redirect("Login.aspx"); } else { Response.Redirect("Registration.aspx"); } } else //register as event host { EventHostModel _host = new EventHostModel(); Eventrix_Client.Registration reg = new Eventrix_Client.Registration(); _host.NAME = txtName.Text; _host.EMAIL = txtEmail.Text; _host.SURNAME = txtSurname.Text; _host.PASS = hashedPass; string response = reg.RegisterHost(_host); if (response.Contains("successfully")) { EmailClient emailClient = new EmailClient(); emailClient.sendMsg_SuccessRegistration(_host); Response.Redirect("Login.aspx"); } else { Response.Redirect("Registration.aspx"); } } }
protected void btnReset_Click(object sender, EventArgs e) { string hashedPass = ""; if ((!txtNewPas.Text.Equals("") && !txtConfirmPas.Text.Equals("") && !txtOldpassword.Text.Equals(""))) { hashedPass = PassWords.HashPassword(txtOldpassword.Text); if (pasword == hashedPass) { proxy = new WebClient(); guestUrl = string.Format("http://localhost:53056/GuestEdit.svc/editGuest/{0},{1},{2},{3},{4},{5},{6}", guestId, txtName.Text, txtLastname.Text, txtEmail.Text, hashedPass, PassWords.HashPassword(txtNewPas.Text), PassWords.HashPassword(txtNewPas.Text)); byte[] _data = proxy.DownloadData(guestUrl); Stream memory = new MemoryStream(_data); var reader = new StreamReader(memory); string result = reader.ReadToEnd().Replace("editGuest", "").Replace("Result", "").Replace(quote + "", "").Replace("{", "").Replace("}", "").Replace(":", ""); btnEdit.Visible = false; //Changing the profile picture if (profilePic.HasFile) { string response = updateProfilePic(profilePic); //Store attribute of the new profile pic in the WCF database if (response.Contains("Success")) { string filename = Path.GetFileName(profilePic.FileName); string serverLocation = "~/Events/" + guestId + "/" + SUBFOLDER + "/" + filename; string SaveLoc = Server.MapPath(serverLocation); //Get the full image directory location profilePic.SaveAs(SaveLoc); //Save the picture in the given directory img = guestClient.getImageById(guestId); if (img == null) { Session["DEFAULT_IMAGE"] = "ProfilePic.png"; } else { imgLocation = img.Location; Session["PROFILE_IMAGE"] = imgLocation.Substring(imgLocation.IndexOf('E')); } } else { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Profile picture failed to update.');", true); } } //Check if the edit is successful or not if (result.Contains("successfully")) { lblWarning.ForeColor = System.Drawing.Color.White; lblWarning.Text = result; lblWarning.Visible = true; Response.Redirect("EditGuest.aspx"); // Refresh the page to display the picture } } else { lblWarning.Text = "Current password is incorrect"; lblWarning.Visible = true; btnReset.Visible = false; } } else { lblWarning.Text = "Cannot edit with empty values"; lblWarning.Visible = true; } }