public void SaveNewContactToRepository()
        {
            // arrange

            // note connection string is in app.config
            Contact con = new Contact();
            ContactsDb db = new ContactsDb();
            con.fname = "Adam";
            con.lname = "VandenElzen";
            con.phone = "867-5309";
            db.Contacts.AddObject(con);

            // act
            db.SaveChanges();

            // Assert -- see if the record retreived from the database matches the one i just added
            Contact savedContact = (from d in db.Contacts where d.id == con.id select d).Single();

            Assert.AreEqual(savedContact.fname, con.fname);
            Assert.AreEqual(savedContact.lname, con.lname);
            Assert.AreEqual(savedContact.phone, con.phone);

            // cleanup
            db.Contacts.DeleteObject(con);
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            int idToupdate = Convert.ToInt32(Request.QueryString["id"].ToString());
               ContactsDb db = new ContactsDb();
               Contact con = db.Contacts.SingleOrDefault(p =>  p.id == idToupdate);

               con.phone = TextBox1.Text;
               db.SaveChanges();

               Label4.Text = "Contact updated Successfully";
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            if (CheckBox1.Checked == true)
            {
                //delete this contact
                int idToupdate = Convert.ToInt32(Request.QueryString["id"].ToString());
                ContactsDb db = new ContactsDb();
                Contact con = db.Contacts.SingleOrDefault(p => p.id == idToupdate);

                db.Contacts.DeleteObject(con);
                db.SaveChanges();
                Response.Redirect("default.aspx");
            }
            return;
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == string.Empty ||
                TextBox2.Text == string.Empty ||
                TextBox3.Text == string.Empty)
            {
                Label1.Text = "Please enter proper details first";
                return;
            }

            Contact con = new Contact();
            con.fname = TextBox1.Text;
            con.lname = TextBox2.Text;
            con.phone = TextBox3.Text;

            ContactsDb db = new ContactsDb();
            db.Contacts.AddObject(con);
            if (db.SaveChanges() == 1)
            {
                Label1.Text = "Contact added Successfully";
            }
        }