コード例 #1
0
        public ActionResult Index([Bind(Include = "Title, ISBN, AuthorName")] NewBook nb)
        {
            Author a = new Author();

            a.AuthorName = nb.AuthorName;
            db.Authors.Add(a);
            db.SaveChanges();

            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.AuthorName);

            b.Authors.Add(author);

            db.Books.Add(b);
            db.SaveChanges();

            MessageClass m = new MessageClass();

            m.MessageText = "Thank you, the book has been added";

            return(View("Result", m));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "BookKey,BookTitle,BookEntryDate,BookISBN")] Book book)
        {
            if (ModelState.IsValid)
            {
                db.Books.Add(book);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(book));
        }
コード例 #4
0
        public ActionResult Create([Bind(Include = "CategoryKey,CategoryName")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
コード例 #5
0
 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;
     }
 }
コード例 #6
0
 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;
     }
 }
    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;
        }
    }
コード例 #8
0
    public int AddAuthor(string authorName)
    {
        int    result = 1;
        Author a      = new Author();

        a.AuthorName = authorName;

        try
        {
            db.Authors.Add(a);
            db.SaveChanges();
        }
        catch (Exception ex) {
            result = 0;
            throw ex;
        }

        return(result);
    }
コード例 #9
0
    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");
    }
コード例 #10
0
        public ActionResult Index([Bind(Include = "BookKey,ReviewerKey, ReviewDate, ReviewTitle, ReviewRating, ReviewText")] Review r)
        {
            r.ReviewerKey = (int)Session["reviewerKey"];
            r.ReviewDate  = DateTime.Now;
            db.Reviews.Add(r);
            db.SaveChanges();
            MessageClass m = new MessageClass();

            m.MessageText = "Thank you for your review";
            return(View("Result", m));
        }
コード例 #11
0
        public ActionResult Index([Bind(Include = "BookKey,ReviewerKey, ReviewDate,ReviewTitle,ReviewRating,ReviewText")] Review r)
        {
            //we basically just take in the review Class
            //I am assigning it the current date
            //We will get the userKey from the session variable
            r.ReviewDate  = DateTime.Now;
            r.ReviewerKey = (int)Session["userKey"];
            db.Reviews.Add(r);
            db.SaveChanges();

            Message m = new Message();

            m.MessageText = "Thanks for the Review";
            return(View("Result", m));
        }
コード例 #12
0
    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;
         }
    }