Exemplo n.º 1
0
        public async Task <int> Create(CoffeeItemDto coffeeItem)
        {
            var sql = @"INSERT INTO Coffee (name, description, caffeineContent)
                            Values (@Name, @Description, @CaffeineContent);
                            SELECT CAST(SCOPE_IDENTITY() as int)";

            using (var conn = sqlServerConnectionProvider.GetDbConnection())
            {
                var result = await conn.QueryAsync <int>(sql,
                                                         new
                {
                    coffeeItem.Name,
                    coffeeItem.Description,
                    coffeeItem.CaffeineContent
                });

                return(result.Single());
            }
        }
Exemplo n.º 2
0
 public async Task <IActionResult> CreateCoffee(CoffeeItemDto coffeeItem)
 {
     return(await mediator.Send(new CreateCoffeeCommand(coffeeItem)));
 }
Exemplo n.º 3
0
 public CreateCoffeeCommand(CoffeeItemDto coffeeItem)
 {
     this.CoffeeItem = coffeeItem;
 }