public async Task <int> Create(CoffeeRatingDto coffeeRating)
        {
            var sql = @"INSERT INTO Rating (coffeeId, comment, rating)
                            Values (@CoffeeId, @Comment, @Rating);
                            SELECT CAST(SCOPE_IDENTITY() as int)";

            await this.coffeeRepository.ThrowExceptionIfCoffeeDoesNotExist(coffeeRating.CoffeeId);

            using (var conn = sqlServerConnectionProvider.GetDbConnection())
            {
                var result = await conn.QueryAsync <int>(sql,
                                                         new
                {
                    coffeeRating.CoffeeId,
                    coffeeRating.Comment,
                    coffeeRating.Rating
                });

                return(result.Single());
            }
        }
Beispiel #2
0
 public async Task <IActionResult> CreateRating(CoffeeRatingDto coffeeRating)
 {
     return(await mediator.Send(new CreateCoffeeRatingCommand(coffeeRating)));
 }
Beispiel #3
0
 public CreateCoffeeRatingCommand(CoffeeRatingDto coffeeRating)
 {
     this.CoffeeRating = coffeeRating;
 }