Пример #1
0
    //gets the user info from the database
    private void GetUserInfo()
    {
        //declare the ADO Entities
        BookReviewDbEntities2 brde = new BookReviewDbEntities2();
        //query the fields
        var info = from i in brde.Reviewers
                   where i.ReviewerUserName.Equals(username)
                   select new { i.ReviewerKey, i.ReviewerHashedPass, i.ReviewerKeyCode };

        //loop through the results and assign the
        //values to the field variables
        foreach (var u in info)
        {
            seed   = u.ReviewerKeyCode;
            dbhash = u.ReviewerHashedPass;
            key    = u.ReviewerKey;
        }
    }
Пример #2
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        try
        {
            BookReviewDbEntities2 db = new BookReviewDbEntities2();
            Reviewer r = new Reviewer();
            r.ReviewerLastName    = txtLastName.Text;
            r.ReviewerFirstName   = txtFirstName.Text;
            r.ReviewerEmail       = txtEmail.Text;
            r.ReviewerUserName    = txtUserName.Text;
            r.ReviewerDateEntered = DateTime.Now;
            r.ReviewPlainPassword = txtPassword.Text;

            KeyCode kc   = new KeyCode();
            int     code = kc.GetKeyCode();

            PasswordHash ph     = new PasswordHash();
            Byte[]       hashed = ph.HashIt(txtPassword.Text, code.ToString());

            r.ReviewerKeyCode    = code;
            r.ReviewerHashedPass = hashed;

            db.Reviewers.Add(r);

            CheckinLog c = new CheckinLog();
            c.CheckinDateTime = DateTime.Now;
            c.Reviewer        = r;
            db.CheckinLogs.Add(c);

            db.SaveChanges();
            lblErrorSuccess.Text = "Reviewer Saved";
        }
        catch (Exception ex)
        {
            lblErrorSuccess.Text = ex.Message;
        }
    }