Skip to content

Commit

Permalink
Return 201 for POST
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasanker committed Nov 12, 2023
1 parent 7f4144d commit 7a6e598
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,17 @@ public ProductsController(IProductService productService, ClaimsUtilities claims
/// </summary>
/// <param name="addProductRequest">The request containing the details of the product to be added and allowed user groups.</param>
/// <returns> The newly added product wrapped in a InitiateProductResponse object.</returns>
/// <response code="200">Product created</response>
/// <response code="201">Product created</response>
/// <response code="409">Product name already exists</response>
[HttpPost]
[AuthorizeRoles(UserGroup.Board)]
[ProducesResponseType(typeof(DetailedProductResponse), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(DetailedProductResponse), StatusCodes.Status201Created)]
[ProducesResponseType(typeof(ApiError), StatusCodes.Status409Conflict)]
public async Task<ActionResult<DetailedProductResponse>> AddProduct([FromBody] AddProductRequest addProductRequest)
{
return Ok(await _productService.AddProduct(addProductRequest));
var product = await _productService.AddProduct(addProductRequest);

return CreatedAtAction(nameof(GetProductById), new { id = product.Id, version = 2 }, product);
}

/// <summary>
Expand Down

0 comments on commit 7a6e598

Please sign in to comment.