コード例 #1
0
        public ActionResult Create(FormCollection collection, int id)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Review temp = new Review
                    {
                        RestaurantID = id,
                        ReviewerName = collection["reviewerName"],
                        ReviewScore  = (float)Convert.ToDouble(collection["reviewScore"]),
                        ReviewText   = collection["reviewText"]
                    };

                    LibHelper.AddReview(temp);

                    return(RedirectToAction("ListReviews/" + id));
                }
                catch (Exception e)
                {
                    return(View());
                }
            }
            else
            {
                return(View("Model State is invalid."));
            }
        }
コード例 #2
0
 //add a review for a restaurant
 public void AddReview(Review review)
 {
     _db.AddReview(ToDataRev(review));
     Debug.Write("Added 1 Review");
 }