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()); } }
public async Task <IActionResult> CreateRating(CoffeeRatingDto coffeeRating) { return(await mediator.Send(new CreateCoffeeRatingCommand(coffeeRating))); }
public CreateCoffeeRatingCommand(CoffeeRatingDto coffeeRating) { this.CoffeeRating = coffeeRating; }