Ejemplo n.º 1
0
        public void DeleteMethodOK()
        {
            //create an instance of the class we want to create
            clsContactUsCollection AContact = new clsContactUsCollection("Fbloggs");
            //create an instance of test data
            clsContactUs TestItem = new clsContactUs();
            //var to store primary key
            Int32 PK = 0;

            //set the properties
            //TestItem.CustomerID = 3;
            TestItem.Email   = "[email protected]";
            TestItem.Name    = "Ayub Osman1";
            TestItem.Message = " I Loved the meal. Thanks !1 ";
            //set ThisCustomer to validate test data
            AContact.ThisContact = TestItem;
            //add the record
            PK = AContact.Add();
            //set primary key of test data
            TestItem.ContactId = PK;
            //find the record
            AContact.ThisContact.Find(PK);
            //delete the record
            AContact.Delete();
            //now find the record
            Boolean Found = AContact.ThisContact.Find(PK);

            //test to see that it exists
            Assert.IsFalse(Found);
        }
Ejemplo n.º 2
0
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to create
            clsContactUsCollection AContact = new clsContactUsCollection("Fbloggs");
            //create an instance of test data
            clsContactUs TestItem = new clsContactUs();
            //var to store primary key
            Int32 PK = 0;

            //set the properties
            TestItem.Email   = "[email protected]";
            TestItem.Name    = "Ayub Osman2";
            TestItem.Message = " I Loved the meal. Thanks !2 ";
            //set ThisCustomer to validate test data
            AContact.ThisContact = TestItem;
            //add the record
            PK = AContact.Add();
            //set primary key of test data
            TestItem.ContactId = PK;
            //modify the record
            TestItem.Email   = "[email protected]";
            TestItem.Name    = "Ayub Osman1";
            TestItem.Message = " I Loved the meal. Thanks !1 ";
            //set the record based on the new record
            AContact.ThisContact = TestItem;
            //update the record
            AContact.Update();
            //find the record
            AContact.ThisContact.Find(PK);
            //test to see that it exists
            Assert.AreEqual(AContact.ThisContact, TestItem);
        }
Ejemplo n.º 3
0
    //function for Adding records
    void Add()
    {
        //create an instance of the booking list
        clsContactUsCollection Contacts = new clsContactUsCollection();
        //validate the data on the web form
        //string foreName, string surname, string dateOfBirth, string gender, string contactNumber, string eMail, string flatNo, string houseNo, string postCode
        String Error = Contacts.ThisContact.Valid(txtEmail.Text, txtName.Text, txtMessage.Text);

        //if the data is OK then add it to the object
        if (Error == "")
        {
            //find the record to update
            //Customer.ThisCustomer.Find(Id);
            //get the data entered by the user
            Contacts.ThisContact.Email   = Convert.ToString(txtEmail.Text);
            Contacts.ThisContact.Name    = Convert.ToString(txtName.Text);
            Contacts.ThisContact.Message = Convert.ToString(txtMessage.Text);
            //CList.ThisCustomer.UserName = User.Identity.Name;
            //update the record
            Contacts.Add();
            //all done so redirect back to the main page
            // Response.Redirect("AdminHomepage.aspx"); page does not exist
            lblError.Text = "add";
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the data entered " + Error;
        }
    }