protected void btnRegister_Click(object sender, EventArgs e) { try{ BookReviewDbEntities db = new BookReviewDbEntities(); Reviewer r = new Reviewer(); r.ReviewerFirstName = txtFirstName.Text; r.ReviewerLastName = txtLastName.Text; r.ReviewerEmail = txtEmail.Text; r.ReviewerUserName = txtUserName.Text; r.ReviewPlainPassword = txtPassword.Text; KeyCode kc = new KeyCode(); int code = kc.GetKeyCode(); r.ReviewerKeyCode = code; PasswordHash ph = new PasswordHash(); Byte[] hashed = ph.HashIt(txtPassword.Text, code.ToString()); r.ReviewerHashedPass = hashed; r.ReviewerDateEntered = DateTime.Now; //save changes db.Reviewers.Add(r); db.SaveChanges(); lblErrorSuccess.Text = "Successfully Registered"; } catch (Exception ex) { lblErrorSuccess.Text = ex.Message; } }
protected void btnRegister_Click(object sender, EventArgs e) { try { BookReviewDbEntities db = new BookReviewDbEntities(); RandomSeed rs = new RandomSeed(); int seed = rs.GetSeed(); PasswordHash ph = new PasswordHash(); Byte[] hashed = ph.HashIt(txtPassword.Text, seed.ToString()); Reviewer rev = new Reviewer(); rev.ReviewerFirstName = txtFirstName.Text; rev.ReviewerUserName = txtUserName.Text; rev.ReviewerLastName = txtLastName.Text; rev.ReviewerEmail = txtEmail.Text; rev.ReviewerDateEntered = DateTime.Now; rev.ReviewPlainPassword = txtPassword.Text; rev.ReviewerKeyCode = seed; rev.ReviewerHashedPass = hashed; db.Reviewers.Add(rev); db.SaveChanges(); lblErrorSuccess.Text = "Reviewer Saved"; } catch (Exception ex) { lblErrorSuccess.Text = ex.Message; } }
public ActionResult Index([Bind(Include = "UserName, Password")] LoginClass lc) { //make a connection to the Entities BookReviewDbEntities db = new BookReviewDbEntities(); //use the stored procedure prebuilt in the database int result = db.usp_ReviewerLogin(lc.UserName, lc.Password); //if the result is valid if (result != -1) { //look up the users key var uID = (from r in db.Reviewers where r.ReviewerUserName.Equals(lc.UserName) select r.ReviewerKey).FirstOrDefault(); //cast it to an int int key = (int)uID; //strore it in a session key Session["userKey"] = key; //create a message class and pass the string to the result view Message msg = new Message("Welcome, " + lc.UserName + ". You can now add and review books."); return(RedirectToAction("Result", msg)); } //if it fails pass this message to the result view Message message = new Message("Invalid Login"); return(View("Result", message)); }
protected void btnRegister_Click(object sender, EventArgs e) { try { BookReviewDbEntities db = new BookReviewDbEntities(); RandomSeed rs = new RandomSeed(); int seed = rs.GetSeed(); PasswordHash ph = new PasswordHash(); Byte[] hashed = ph.HashIt(txtPassword.Text, seed.ToString()); Reviewer rev = new Reviewer(); rev.ReviewerFirstName = txtFirstName.Text; rev.ReviewerUserName = txtUserName.Text; rev.ReviewerLastName = txtLastName.Text; rev.ReviewerEmail = txtEmail.Text; rev.ReviewerDateEntered = DateTime.Now; rev.ReviewPlainPassword = txtPassword.Text; rev.ReviewerKeyCode = seed; rev.ReviewerHashedPass = hashed; db.Reviewers.Add(rev); db.SaveChanges(); lblErrorSuccess.Text = "Reviewer Saved"; } catch(Exception ex) { lblErrorSuccess.Text = ex.Message; } }
public ActionResult Index([Bind(Include = "Title, ISBN, Author")] NewBookClass nb) { BookReviewDbEntities db = new BookReviewDbEntities(); Author a = new Author(); a.AuthorName = nb.Author; db.Authors.Add(a); db.SaveChanges(); // for donation get userkey from the session Book b = new Book(); b.BookTitle = nb.Title; b.BookISBN = nb.ISBN; b.BookEntryDate = DateTime.Now; Author author = db.Authors.FirstOrDefault (x => x.AuthorName == nb.Author); b.Authors.Add(author); db.Books.Add(b); db.SaveChanges(); Message m = new Message(); m.MessageText = "Thank you, the book has been added"; return(View("Result", m)); }
protected void Page_Load(object sender, EventArgs e) { BookReviewDbEntities db = new BookReviewDbEntities(); var auths = (from a in db.Authors select a).ToList(); GridView.DataSource = auths; GridView.DataBind(); }
public ActionResult Index() { BookReviewDbEntities db = new BookReviewDbEntities(); //var bks = (from b in db.Books // select b).ToList(); return(View(db.Books.ToList())); }
public ActionResult Index() { // add ref to Entities BookReviewDbEntities db = new BookReviewDbEntities(); //return books as a list return(View(db.Books.ToList())); }
protected void SubmitButton_Click(object sender, EventArgs e) { BookReviewDbEntities db = new BookReviewDbEntities(); Author a = new Author(); a.AuthorName = AuthorTextBox.Text; db.Authors.Add(a); db.SaveChanges(); Response.Redirect("AuthorList.aspx"); }
//gets the user info from the database private void GetUserInfo() { //declare the ADO Entities BookReviewDbEntities brde = new BookReviewDbEntities(); //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; } }
protected void SubmitButton_Click(object sender, EventArgs e) { string user = UserTextBox.Text; string first = FirstNameTextBox.Text; string last = LastNameTextBox.Text; string email = EmailTextBox.Text; string password = ConfirmTextBox.Text; BookReviewDbEntities db = new BookReviewDbEntities(); int result = db.usp_NewReviewer(user, first, last, email, password); if (result != -1) { Response.Redirect("Default.aspx"); } else { ErrorLabel.Text = "Something went terribly wrong"; } }
protected void LoginButton_Click(object sender, EventArgs e) { int key = 0; BookReviewDbEntities db = new BookReviewDbEntities(); int success = db.usp_ReviewerLogin(UserTextBox.Text, PasswordTextBox.Text); if (success != -1) { var uKey = (from k in db.Reviewers where k.ReviewerUserName.Equals(UserTextBox.Text) select k.ReviewerKey).FirstOrDefault(); key = (int)uKey; Session["userKey"] = key; Response.Redirect("Author.aspx"); } else { ResultLabel.Text = "Invalid Login"; } }
public ActionResult Index([Bind(Include = "UserName, Password")] LoginClass lc) { BookReviewDbEntities db = new BookReviewDbEntities(); int loginResult = db.usp_ReviewerLogin(lc.UserName, lc.Password); if (loginResult != -1) { var uid = (from r in db.Reviewers where r.ReviewerUserName.Equals(lc.UserName) select r.ReviewerKey).FirstOrDefault(); int rKey = (int)uid; Session["reviewerKey"] = rKey; MessageClass msg = new MessageClass(); msg.MessageText = "Thank You, " + lc.UserName + " for logging in. You can now donate or apply for assistance."; return(RedirectToAction("Result", msg)); } MessageClass message = new MessageClass(); message.MessageText = "Invalid Login"; return(View("Result", message)); }
//overloaded Index method public ActionResult Index([Bind(Include = "UserName, Password, ReviewerKey")] LoginClass loginClass) { //make connection to Ado Entity model classes BookReviewDbEntities br = new BookReviewDbEntities(); //Assign review key a value of 0 loginClass.ReviewerKey = 0; //pass the values to the stored procedure and get result (-1 = failure) int result = br.usp_ReviewerLogin(loginClass.UserName, loginClass.Password); //test the results if (result != -1) { //run a query to get the ReviewerKey var ukey = (from r in br.Reviewers where r.ReviewerUserName.Equals(loginClass.UserName) select r.ReviewerKey).FirstOrDefault(); loginClass.ReviewerKey = (int)ukey; } //return the class to the Result view return(View("Result", loginClass)); }
protected void btnRegister_Click(object sender, EventArgs e) { try{ BookReviewDbEntities db = new BookReviewDbEntities(); 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; } }
protected void loginbutton_Click(object sender, EventArgs e) { int key = 0; BookReviewDbEntities db = new BookReviewDbEntities(); int success = db.usp_ReviewerLogin(usertextbox.Text, passwordtextbox.Text); if (success != -1) { var uKey = (from K in db.Reviewers where K.ReviewerUserName.Equals(usertextbox.Text) select K.ReviewerKey).FirstOrDefault(); key = (int)uKey; Session["userkey"] = key; ResultLabel.Text = " Helloooo" + key.ToString(); } else { ResultLabel.Text = " Errrrr"; } }
public ActionResult Index() { BookReviewDbEntities db = new BookReviewDbEntities(); return(View(db.Books.ToList())); }