hinzufügen von weitern methoden zu katalog
This commit is contained in:
parent
62edba4f2c
commit
ea2211c99e
6 changed files with 63 additions and 4 deletions
|
@ -25,18 +25,76 @@ namespace BuecherwurmAPI.Controllers
|
||||||
return Ok(books);
|
return Ok(books);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET Katalog/{id}
|
// POST Katalog
|
||||||
|
[HttpPost]
|
||||||
|
public ActionResult<IEnumerable<Book>> 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")]
|
[HttpGet("{id}", Name ="GetBookByID")]
|
||||||
public ActionResult <IEnumerable<Book>> GetBookByID(int id)
|
public ActionResult <IEnumerable<Book>> GetBookByID(int id)
|
||||||
{
|
{
|
||||||
var bookItem = _repository.GetBookById(id);
|
var book = _repository.GetBookById(id);
|
||||||
if (bookItem != null)
|
if (book != null)
|
||||||
{
|
{
|
||||||
return Ok(bookItem);
|
return Ok(book);
|
||||||
}
|
}
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PUT Katalog/{id}
|
||||||
|
[HttpPut("id")]
|
||||||
|
public ActionResult<IEnumerable<Book>> 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<IEnumerable<Book>> BuchEntfernen (int id)
|
||||||
|
{
|
||||||
|
var book = _repository.GetBookById(id);
|
||||||
|
if(book == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
_repository.BuchEntfernen(book);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,5 +7,6 @@ namespace BuecherwurmAPI.Data
|
||||||
{
|
{
|
||||||
IEnumerable<Book> GetAllBooks();
|
IEnumerable<Book> GetAllBooks();
|
||||||
Book GetBookById(int id);
|
Book GetBookById(int id);
|
||||||
|
void BuchEntfernen(Book book);
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue