Exemplo n.º 1
0
        public ActionResult New(FormCollection form)
        {
            if (Session["userID"] == null)
                return RedirectToAction("Login", "User", new { id = Convert.ToInt32(form["contractorUserID"]) });

            Review newReview = new Review();
            newReview.userID = (int)Session["userID"];
            newReview.contractorUserID = Convert.ToInt32(form["contractorUserID"]);
            newReview.review1 = form["review1"];

            List<RatingQuestion> questions = newReview.getQuestions();
            newReview.ratings = new double[questions.Count()][];
            int count = 0;
            foreach (RatingQuestion q in questions) {
                newReview.ratings[count] = new double[2] {q.ratingQuestionID, Convert.ToDouble(form["rating"+count])};
                count++;
            }

            if (ModelState.IsValid) {
                newReview.Save();
                return RedirectToAction("Profile", "User", new { id = Convert.ToInt32(form["contractorUserID"]) });
            }

            // Otherwise, reshow form
            TryUpdateModel(newReview);
            return View(newReview);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Reviews EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToReviews(Review review)
 {
     base.AddObject("Reviews", review);
 }
 /// <summary>
 /// Create a new Review object.
 /// </summary>
 /// <param name="reviewID">Initial value of the reviewID property.</param>
 /// <param name="userID">Initial value of the userID property.</param>
 /// <param name="contractorUserID">Initial value of the contractorUserID property.</param>
 /// <param name="review1">Initial value of the review1 property.</param>
 public static Review CreateReview(global::System.Int32 reviewID, global::System.Int32 userID, global::System.Int32 contractorUserID, global::System.String review1)
 {
     Review review = new Review();
     review.reviewID = reviewID;
     review.userID = userID;
     review.contractorUserID = contractorUserID;
     review.review1 = review1;
     return review;
 }