From 7fc04455f675764916fc7065f63131ad06eded2a Mon Sep 17 00:00:00 2001 From: David Renner Date: Wed, 3 Jun 2020 09:59:29 +0200 Subject: [PATCH] catched 304 --- Controllers/ItemController.cs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Controllers/ItemController.cs b/Controllers/ItemController.cs index db46e8c..cef6f42 100644 --- a/Controllers/ItemController.cs +++ b/Controllers/ItemController.cs @@ -23,15 +23,31 @@ namespace BuecherwurmAPI.Controllers public ActionResult> GetAllItems() { var items = _repository.GetAllItems(); - return Ok(items); + if (items != null) + { + return Ok(items); + } + return NoContent(); } // POST Inventar [HttpPost] public ActionResult> 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 + } + }