using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using BuecherwurmAPI.Data; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.JsonPatch; using Microsoft.Extensions.Logging; using BuecherwurmAPI.Models; namespace BuecherwurmAPI.Controllers { [Route("api/leihvorgang")] [ApiController] public class LendController : ControllerBase { private readonly ILendRepo _repository; public LendController(ILendRepo repository) { _repository = repository; } //GET api/leihvorgang [HttpGet] public ActionResult> LendsGet() { return Ok(_repository.GetAllLends()); } //POST api/leihvorgang [HttpPost] public ActionResult LendsPost(Lend lend) { return Ok(new Lend{Id = lend.Id, Customer = lend.Customer, Returned = lend.Returned, ItemId = lend.ItemId, ReturnDate = lend.ReturnDate}); } //GET api/leihvorgang/{id} [HttpGet("{id}")] public ActionResult LendById(int id) { var lend = _repository.GetLendById(id); return Ok(lend); } //PATCH api/leihvorgang/{id} [HttpPatch("{id}")] public ActionResult LendPatchById(int id, JsonPatchDocument patchDocument) { var lend = _repository.GetLendById(id); if (lend == null) { return NotFound(); } return Ok(); } } }