catched 304

This commit is contained in:
David Renner 2020-06-03 09:59:29 +02:00
parent de7bc0871d
commit 7fc04455f6
1 changed files with 19 additions and 3 deletions

View File

@ -23,15 +23,31 @@ namespace BuecherwurmAPI.Controllers
public ActionResult<IEnumerable<Item>> GetAllItems()
{
var items = _repository.GetAllItems();
return Ok(items);
if (items != null)
{
return Ok(items);
}
return NoContent();
}
// POST Inventar
[HttpPost]
public ActionResult<IEnumerable<Item>> NewItem(ItemPost item)
{
var newItem = _repository.NewItem(item);
return Ok(newItem);
try
{
var newItem = _repository.NewItem(item);
if (item != null)
{
return Ok(newItem);
}
return NotFound();
}
catch (System.Exception)
{
return StatusCode(304); //not Modified
}
}