public async Task <int> Update(UpdateCoffeeRatingDto coffeeRating)
        {
            var sql = @"UPDATE Rating
                        SET comment = @Comment, rating = @Rating
                        WHERE Id = @Id;";

            await ThrowExceptionIfCoffeeRatingDoesNotExist(coffeeRating.Id);

            using (var conn = sqlServerConnectionProvider.GetDbConnection())
            {
                return(await conn.ExecuteAsync(sql, new
                {
                    coffeeRating.Id,
                    coffeeRating.Comment,
                    coffeeRating.Rating
                }));
            }
        }
Example #2
0
 public async Task <IActionResult> UpdateRating(int coffeeRatingId, UpdateCoffeeRatingDto updateCoffeeRating)
 {
     return(await mediator.Send(new UpdateCoffeeRatingCommand(coffeeRatingId, updateCoffeeRating)));
 }
Example #3
0
 public UpdateCoffeeRatingCommand(int coffeeRatingId, UpdateCoffeeRatingDto updateCoffeeRating)
 {
     this.CoffeeRatingId     = coffeeRatingId;
     this.UpdateCoffeeRating = updateCoffeeRating;
 }