protected void btnAddQuestion_Click(object sender, EventArgs e) { FrontCodeBusiness fcb = new FrontCodeBusiness(); fcb.AddNewQuestions(txtQuestionDesc.Text); DataTable dt = fcb.FindQuestionID(); int questionID = Convert.ToInt32(dt.Rows[0]["QuestionID"].ToString()); for (int i = 0; i < 4; i++) { if (i == 0) { fcb.AddOptionsToQuestion(questionID, txtOption1.Text); } if (i == 1) { fcb.AddOptionsToQuestion(questionID, txtOption2.Text); } if (i == 2) { fcb.AddOptionsToQuestion(questionID, txtOption3.Text); } if (i == 3) { fcb.AddOptionsToQuestion(questionID, txtOption4.Text); } } ResetForm(); }
private string RetriveSaltedHash() { User user = new User { UserName = txtUsername.Text }; FrontCodeBusiness fcb = new FrontCodeBusiness { UserObj = user }; string takeSalt = fcb.RetriveSaltAgainstUser(); string takeHash; if (takeSalt != null) { takeHash = GenerateTempHashWithSalt(takeSalt); } else { takeHash = null; } return(takeHash); }
private bool IsAlreadyExists() { bool uExists = false; bool eExists = false; User user = new User { UserName = txtUsername.Text, Email = txtEmail.Text }; FrontCodeBusiness fcb = new FrontCodeBusiness { UserObj = user }; DataTable dt = fcb.IsUserNameExists(); if (dt.Rows.Count > 0) { uExists = dt.Rows[0]["UserNameExists"].ToString().Equals("0") ? false : true; } dt = fcb.IsEmailExists(); if (dt.Rows.Count > 0) { eExists = dt.Rows[0]["EmailExists"].ToString().Equals("0") ? false : true; } return((uExists == false && eExists == false) ? false : true); }
public void UserNameExists(string username) { User user = new User { UserName = username }; user.UserNameInUse = false; FrontCodeBusiness fcb = new FrontCodeBusiness { UserObj = user }; DataTable dt = fcb.IsUserNameExists(); if (dt.Rows.Count > 0) { user.UserNameInUse = dt.Rows[0]["UserNameExists"].ToString().Equals("0") ? false : true; } JavaScriptSerializer js = new JavaScriptSerializer(); Context.Response.Write(js.Serialize(user)); }
private void LoadEnrollCourses() { FrontCodeBusiness fab = new FrontCodeBusiness(); rptEnrollCourses.DataSource = fab.SelectEnrollCourses(); rptEnrollCourses.DataBind(); }
public void EmailExists(string email) { User user = new User { Email = email }; user.EmailInUse = false; FrontCodeBusiness fcb = new FrontCodeBusiness { UserObj = user }; DataTable dt = fcb.IsEmailExists(); if (dt.Rows.Count > 0) { user.EmailInUse = dt.Rows[0]["EmailExists"].ToString().Equals("0") ? false : true; } JavaScriptSerializer js = new JavaScriptSerializer(); Context.Response.Write(js.Serialize(user)); }
private void LoadAllQuestionsAndOptions() { FrontCodeBusiness fcb = new FrontCodeBusiness(); DataTable dt = fcb.SelectQuestions(); Session["Questions"] = dt; scoresFlag = new int[dt.Rows.Count]; FillWithDummy(); SetQuestion(); }
protected void btnResetPassword_Click(object sender, EventArgs e) { User user = new User { Email = txtEmail.Text }; FrontCodeBusiness fcb = new FrontCodeBusiness { UserObj = user }; DataTable dt = fcb.ResetPassword(); if (dt.Rows.Count > 0) { string returnCode = dt.Rows[0]["ReturnCode"].ToString(); if (returnCode.Equals("1")) { string username = dt.Rows[0]["Username"].ToString(); string toEmail = dt.Rows[0]["Email"].ToString(); string uniqueID = dt.Rows[0]["UniqueID"].ToString(); try { SendPasswordResetMail(toEmail, username, uniqueID); Session["RedirectPageMessage"] = "An email with instructions to <span style='color:#ff8888'>RESET</span> your password is sent to your email address."; txtEmail.Text = string.Empty; Response.Redirect("~/UI/Redirect.aspx"); } catch (Exception ex) { ExceptionLogger.Log(ex); lblStatus.Text = "An unknown error occured!"; lblStatus.ForeColor = System.Drawing.Color.Red; } } else { lblStatus.Text = "Email not found!"; lblStatus.ForeColor = System.Drawing.Color.Red; } } else { lblStatus.Text = "Email not found!"; lblStatus.ForeColor = System.Drawing.Color.Red; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["UserWholeRecord"] != null) { string guid = Request.QueryString["CID"].ToString(); FrontCodeBusiness fcb = new FrontCodeBusiness(); fcb.AddNewEnrolledCourse(guid); } else { Response.Redirect("~/UI/UserLogin.aspx"); } } }
private bool ChangeUserPassword() { string GUID = Request.QueryString["uid"]; string salt; string hash = HashingAndSalting.CreateSaltedHash(txtNewPassword.Text, out salt); User user = new User { GlobalUniqueIDForResetPassword = GUID, Password = txtNewPassword.Text, Salt = salt, Hash = hash }; FrontCodeBusiness fcb = new FrontCodeBusiness { UserObj = user }; return(fcb.IsPasswordChanged()); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { User user = new User { GlobalUniqueIDForResetPassword = Request.QueryString["uid"] }; FrontCodeBusiness ecb = new FrontCodeBusiness { UserObj = user }; if (!ecb.IsPasswordResetLinkValid()) { Response.Clear(); Response.Write("<h1 style='color:red;'>Password reset link has expired or invalid link!</h1>"); Response.End(); } } }
private void SetQuestion() { FrontCodeBusiness fcb = new FrontCodeBusiness(); DataTable dt = (DataTable)Session["Questions"]; if (dt.Rows.Count > counter) { questionTitle.InnerText = dt.Rows[counter]["QuestionDescription"].ToString(); dt = fcb.SelectOptionsByQuestion(counter + 1); rbl.DataSource = dt; rbl.DataTextField = "OptionDescription"; rbl.DataValueField = "OptionDescription"; rbl.DataBind(); } else { contentDiv.Style.Add("display", "none"); finDiv.Style.Add("display", "block"); CalculateScore(); } }