コード例 #1
0
        public async Task <CocktailReview> CreateCocktailReviewAsync(double rating, string comment, Cocktail cocktail, User user)
        {
            user.EnsureNotNull();
            cocktail.EnsureNotNull();

            var review = new CocktailReview
            {
                Rating     = rating,
                Comment    = comment,
                UserName   = user.UserName,
                Cocktail   = cocktail,
                CocktailId = cocktail.Id,
                User       = user,
                UserID     = user.Id,
            };

            await this.context.CocktailReviews.AddAsync(review);

            await this.context.SaveChangesAsync();

            return(review);
        }