diff --git a/Controllers/KatalogController.cs b/Controllers/KatalogController.cs index 0f7fbd2..b2412dd 100644 --- a/Controllers/KatalogController.cs +++ b/Controllers/KatalogController.cs @@ -25,18 +25,76 @@ namespace BuecherwurmAPI.Controllers return Ok(books); } - // GET Katalog/{id} + // POST Katalog + [HttpPost] + public ActionResult> NeuesBuch(Book book) + { + + return Ok(new Book + { + Name = book.Name, + Author= book.Author, + Country= book.Country, + Link= book.Link, + Language= book.Language, + Pages= book.Pages, + Year=book.Year, + ProductId =book.ProductId, + Category= book.Category, + ImageLink =book.ImageLink, + LendTime =book.LendTime, + LendType = book.LendType + }); + } + + + // GET katalog/{id} [HttpGet("{id}", Name ="GetBookByID")] public ActionResult > GetBookByID(int id) { - var bookItem = _repository.GetBookById(id); - if (bookItem != null) + var book = _repository.GetBookById(id); + if (book != null) { - return Ok(bookItem); + return Ok(book); } return NoContent(); } + + // PUT Katalog/{id} + [HttpPut("id")] + public ActionResult> BuchBearbeiten(Book book) + { + return Ok(new Book + { + Name = book.Name, + Author= book.Author, + Country= book.Country, + Link= book.Link, + Language= book.Language, + Pages= book.Pages, + Year=book.Year, + ProductId =book.ProductId, + Category= book.Category, + ImageLink =book.ImageLink, + LendTime =book.LendTime, + LendType = book.LendType + }); + } + + // DELETE katalog/{id} + [HttpDelete("id")] + public ActionResult> BuchEntfernen (int id) + { + var book = _repository.GetBookById(id); + if(book == null) + { + return NotFound(); + } + _repository.BuchEntfernen(book); + return NoContent(); + } + } } \ No newline at end of file diff --git a/Data/IBookRepo.cs b/Data/IBookRepo.cs index 9ce4101..b81d051 100644 --- a/Data/IBookRepo.cs +++ b/Data/IBookRepo.cs @@ -7,5 +7,6 @@ namespace BuecherwurmAPI.Data { IEnumerable GetAllBooks(); Book GetBookById(int id); + void BuchEntfernen(Book book); } } \ No newline at end of file diff --git a/bin/Debug/netcoreapp3.1/BuecherwurmAPI.dll b/bin/Debug/netcoreapp3.1/BuecherwurmAPI.dll index 09df22c..e7b48c6 100644 Binary files a/bin/Debug/netcoreapp3.1/BuecherwurmAPI.dll and b/bin/Debug/netcoreapp3.1/BuecherwurmAPI.dll differ diff --git a/bin/Debug/netcoreapp3.1/BuecherwurmAPI.pdb b/bin/Debug/netcoreapp3.1/BuecherwurmAPI.pdb index b9000bc..befe0d9 100644 Binary files a/bin/Debug/netcoreapp3.1/BuecherwurmAPI.pdb and b/bin/Debug/netcoreapp3.1/BuecherwurmAPI.pdb differ diff --git a/obj/Debug/netcoreapp3.1/BuecherwurmAPI.dll b/obj/Debug/netcoreapp3.1/BuecherwurmAPI.dll index 09df22c..e7b48c6 100644 Binary files a/obj/Debug/netcoreapp3.1/BuecherwurmAPI.dll and b/obj/Debug/netcoreapp3.1/BuecherwurmAPI.dll differ diff --git a/obj/Debug/netcoreapp3.1/BuecherwurmAPI.pdb b/obj/Debug/netcoreapp3.1/BuecherwurmAPI.pdb index b9000bc..befe0d9 100644 Binary files a/obj/Debug/netcoreapp3.1/BuecherwurmAPI.pdb and b/obj/Debug/netcoreapp3.1/BuecherwurmAPI.pdb differ