diff --git a/BuecherwurmAPI.csproj b/BuecherwurmAPI.csproj
index 400722f..fdec702 100644
--- a/BuecherwurmAPI.csproj
+++ b/BuecherwurmAPI.csproj
@@ -4,5 +4,9 @@
netcoreapp3.1
+
+
+
+
diff --git a/Controllers/LendController.cs b/Controllers/LendController.cs
index 40f02fc..559ef27 100644
--- a/Controllers/LendController.cs
+++ b/Controllers/LendController.cs
@@ -4,6 +4,7 @@ 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;
@@ -13,27 +14,45 @@ namespace BuecherwurmAPI.Controllers
[ApiController]
public class LendController : ControllerBase
{
- private ILendRepo _repository;
+ private readonly ILendRepo _repository;
public LendController(ILendRepo repository)
{
_repository = repository;
}
- //GET api/leihvorgang/
+ //GET api/leihvorgang
[HttpGet]
- public ActionResult> GetAllLends()
+ public ActionResult> LendsGet()
{
- var lends = _repository.GetAllLends();
- return Ok(lends);
+ 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 GetLend(int 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();
+ }
}
}