コード例 #1
0
        public void AddRating(Rating rating)
        {
            Rating ratingFromDb = _ratingsRepository.GetRating(rating.RecipeId, rating.UserId);

            if (ratingFromDb == null)
            {
                _ratingsRepository.PostRating(rating);
            }
            else
            {
                ratingFromDb.Rate = rating.Rate;
                _ratingsRepository.PutRating(ratingFromDb);
            }
        }
コード例 #2
0
        public int GetRating(int recipeId, string userId)
        {
            Rating rating = _ratingsRepository.GetRating(recipeId, userId);

            return(rating == null ? 0 : rating.Rate);
        }