using System.Collections.Generic; using BuecherwurmAPI.Models; using Microsoft.AspNetCore.Mvc; using System.Linq; using Microsoft.EntityFrameworkCore; using BuecherwurmAPI.Data; namespace BuecherwurmAPI.Controllers { [Route("inventar")] [ApiController] public class InventarController : ControllerBase { private readonly IBookRepo _repository; public InventarController(IBookRepo repository) { _repository = repository; } // GET Inventar [HttpGet] public ActionResult> GetAllCopies() { var copies = _repository.GetAllCopies(); return Ok(copies); } // POST Inventar [HttpPost] public ActionResult> NeuesExemplar(Copy copy) { return Ok(new Copy { CopyId = copy.CopyId, ProductId = book.ProductId, LendTime = copy.LendTime, LendType = copy.LendType }); } // GET Inventar/{id} [HttpGet("{id}", Name = "GetCopyByID")] public ActionResult> GetCopyByID(int id) { var copy = _repository.GetCopyById(id); if (copy != null) { return Ok(copy); } return NoContent(); } // 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(); }*/ } }