pipeline und controller
This commit is contained in:
@@ -16,11 +16,19 @@ namespace Webshop.Api.Controllers
|
||||
_productService = productService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<ProductDto>>> GetAllProducts()
|
||||
{
|
||||
var products = await _productService.GetAllProductsAsync();
|
||||
return Ok(products);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ProductDto>> CreateProduct([FromBody] ProductDto productDto)
|
||||
{
|
||||
var createdProduct = await _productService.CreateProductAsync(productDto);
|
||||
|
||||
return CreatedAtAction(nameof(GetAllProducts), new { id = createdProduct.Id }, createdProduct);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user