BuecherwurmAPI/Controllers/LendController.cs

40 lines
1008 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BuecherwurmAPI.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using BuecherwurmAPI.Models;
namespace BuecherwurmAPI.Controllers
{
[Route("api/leihvorgang")]
[ApiController]
public class LendController : ControllerBase
{
private ILendRepo _repository;
public LendController(ILendRepo repository)
{
_repository = repository;
}
//GET api/leihvorgang/
[HttpGet]
public ActionResult<IEnumerable<Lend>> GetAllLends()
{
var lends = _repository.GetAllLends();
return Ok(lends);
}
//GET api/leihvorgang/{id}
[HttpGet("{id}")]
public ActionResult<Lend> GetLend(int id)
{
var lend = _repository.GetLendById(id);
return Ok(lend);
}
}
}