obsługa dodawania produktów o nieprawidłowym typie i/lub dostępności

This commit is contained in:
kamil 2024-06-11 23:54:30 +02:00
parent 04334f59c0
commit ca6a02205b

View File

@ -39,6 +39,14 @@ namespace FirmTracker_Server.Controllers
[ProducesResponseType(400)] // Bad Request
public IActionResult CreateProduct([FromBody] Product product)
{
if (product.Type != 0 && product.Type != 1)
{
return BadRequest("Product type must be set to 0 or 1");
}
if (product.Type == 0 && product.Availability != 0)
{
return BadRequest("Services availability must be set to 0");
}
try
{
_productCrud.AddProduct(product);
@ -81,6 +89,14 @@ namespace FirmTracker_Server.Controllers
{
if (id != product.Id)
return BadRequest("Product ID mismatch");
if (product.Type != 0 && product.Type != 1)
{
return BadRequest("Product type must be set to 0 or 1");
}
if (product.Type == 0 && product.Availability != 0)
{
return BadRequest("Services availability must be set to 0");
}
try
{