Example #1
0
 protected void submitReview(bool bIsLoggedIn)
 {
     //make a new review object
     Review review = new Review();
     //set the chapter ID to the selected value of ddlChapterList
     review.ChapterID = new Guid(this.ddlChapterList.SelectedValue);
     //set GuestName to txtGuestReviewer.Text
     review.GuestName = this.txtGuestReviewer.Text;
     //if statement that will run if bIsLoggedIn is equal to 'true'
     if (bIsLoggedIn == true)
     {
         //set GuestName property of review to text from lblReviewerName
         review.GuestName = lblReviewerName.Text;
         //set UserId property of review to a guid taken from Session "UserID"
         review.UserID = new Guid(Session["UserID"].ToString());
     }
     //else bIsLoggedIn is equal to 'false' so do this
     else
     {
         //set GuestName property of review to text from txtGuestReviewer
         review.GuestName = txtGuestReviewer.Text;
         //set UserId property of review to an empty guid
         review.UserID = Guid.Empty;
     }
     //set ReviewContent property of review to text from txtReview
     review.ReviewContent = txtReview.Text;
     //if statement that will run if review is savable
     if (review.IsSavable() == true)
     {
         //if savable, save it
         review = review.Save();
         //empty the text of txtReview and txtGuestReviewer
         txtReview.Text = null;
         txtGuestReviewer.Text = null;
     }
 }