コード例 #1
0
        public void SaveReview(Review1 review)
        {
            if (review.ReviewId == 0)
            {
                context.Reviews.Add(review);
            }
            else
            {
                Review1 reviewEntry = context.Reviews
                                      .FirstOrDefault(r => r.ReviewId == review.ReviewId);

                if (reviewEntry != null)
                {
                    reviewEntry.ReviewBody = review.ReviewBody;
                    reviewEntry.Rating     = review.Rating;
                    //Add RecipeId
                    reviewEntry.RecipeId = review.RecipeId;
                }
            }
            context.SaveChanges();
        }
コード例 #2
0
 public static void AddReviews(Review1 review)
 {
     reviews.Add(review);
 }