public void UpdateMethodOK() { //create an instance of the class we want to create clsReviewsCollection AllReviews = new clsReviewsCollection("Fbloggs"); //create an instance of test data clsReviews TestItem = new clsReviews(); //var to store primary key Int32 PK = 0; //set the properties TestItem.Email = "*****@*****.**"; TestItem.Exp = "*****@*****.**"; TestItem.Improveexp = "*****@*****.**"; //set ThisCustomer to validate test data AllReviews.ThisReview = TestItem; //add the record PK = AllReviews.Add(); //set primary key of test data TestItem.ReviewId = PK; //modify the record TestItem.Email = "*****@*****.**"; TestItem.Exp = "*****@*****.**"; TestItem.Improveexp = "*****@*****.**"; //set the record based on the new record AllReviews.ThisReview = TestItem; //update the record AllReviews.Update(); //find the record AllReviews.ThisReview.Find(PK); //test to see that it exists Assert.AreEqual(AllReviews.ThisReview, TestItem); }
public void updateMethodOK() { clsReviewsCollection AllReviews = new clsReviewsCollection(); clsReviews TestItem = new clsReviews(); Int32 PrimaryKey = 0; TestItem.ReviewApproved = true; TestItem.ReviewRating = 4; TestItem.ReviewerName = "Dave"; TestItem.ReviewText = "Good Product"; TestItem.ReviewedProduct = "Spurs Shorts"; TestItem.DateAdded = DateTime.Now.Date; AllReviews.ThisReviews = TestItem; PrimaryKey = AllReviews.Add(); TestItem.ReviewsId = PrimaryKey; //PrimaryKey = AllReviews = TestItem; //AllReviews.ThisReviews.Add(); TestItem.ReviewApproved = false; TestItem.ReviewRating = 2; TestItem.ReviewerName = "Dom"; TestItem.ReviewText = "Ok Product"; TestItem.ReviewedProduct = " Shorts"; TestItem.DateAdded = DateTime.Now.Date; AllReviews.ThisReviews = TestItem; AllReviews.Update(); AllReviews.ThisReviews.Find(PrimaryKey); Assert.AreEqual(AllReviews.ThisReviews, TestItem); }
void Update() { //create an instance of the booking list clsReviewsCollection Review = new clsReviewsCollection(User.Identity.Name); //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 = Review.ThisReview.Valid(txtEmail.Text, txtExp.Text, txtImproveexp.Text); //if the data is OK then add it to the object if (Error == "") { //find the record to update Review.ThisReview.Find(ReviewId); //get the data entered by the user Review.ThisReview.Email = Convert.ToString(txtEmail.Text); Review.ThisReview.Exp = Convert.ToString(txtExp.Text); Review.ThisReview.Improveexp = Convert.ToString(txtImproveexp.Text); //CList.ThisCustomer.UserName = User.Identity.Name; //update the record Review.Update(); //all done so redirect back to the main page // Response.Redirect("AdminHomepage.aspx"); lblError.Text = "update"; } else { //report an error lblError.Text = "There were problems with the data entered " + Error; } }