Add product by id handler

This commit is contained in:
lumijiez
2025-06-26 01:36:12 +03:00
parent a8ea4b41ee
commit c7dcbc1926
4 changed files with 60 additions and 3 deletions

View File

@@ -21,6 +21,18 @@ public class ProductsController(IMediator mediator) : ControllerBase
return Ok(result);
}
[HttpGet("{id:guid}")]
[AllowAnonymous]
public async Task<ActionResult<PagedResultDto<ProductDto>>> GetProductById(
Guid id,
CancellationToken cancellationToken)
{
var result = await mediator
.Send(new GetProductByIdQuery { ProductId = id}, cancellationToken);
return Ok(result);
}
[HttpPost]
[Authorize(Roles = "Admin")]
public async Task<ActionResult<PagedResultDto<ProductDto>>> CreateProduct(