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); } }
public int GetRating(int recipeId, string userId) { Rating rating = _ratingsRepository.GetRating(recipeId, userId); return(rating == null ? 0 : rating.Rate); }