diff --git a/Controllers/ItemController.cs b/Controllers/ItemController.cs index 33d1135..83506c0 100644 --- a/Controllers/ItemController.cs +++ b/Controllers/ItemController.cs @@ -8,17 +8,17 @@ using Microsoft.Data.Sqlite; namespace BuecherwurmAPI.Controllers { - [Route("inventar")] + [Route("api/inventar")] [ApiController] public class ItemController : ControllerBase { - private readonly IItemRepo _repository; + private readonly ItemModel _repository; - public ItemController(IItemRepo repository) + public ItemController(IModel repository) { - _repository = repository; + _repository = (ItemModel)repository; } - // GET Inventar + // GET api/inventar [HttpGet] public ActionResult> GetAllItems() { @@ -26,7 +26,7 @@ namespace BuecherwurmAPI.Controllers return Ok(items); } - // POST Inventar + // POST api/inventar [HttpPost] public ActionResult> NewItem(ItemPost item) @@ -36,7 +36,7 @@ namespace BuecherwurmAPI.Controllers } - // GET Inventar/{id} + // GET api/nventar/{id} [HttpGet("{itemId}")] public ActionResult> GetItemByID(long id) { @@ -48,7 +48,7 @@ namespace BuecherwurmAPI.Controllers return NoContent(); } - // DELETE inventory/{id} + // DELETE api/inventar/{id} [HttpDelete("itemId")] public ActionResult> DeleteItem(long itemId) diff --git a/Controllers/LendController.cs b/Controllers/LendController.cs index b18ff9b..6ec0b63 100644 --- a/Controllers/LendController.cs +++ b/Controllers/LendController.cs @@ -19,9 +19,9 @@ namespace BuecherwurmAPI.Controllers private readonly LendModel _repository; private readonly IMapper _mapper; - public LendController(SqliteConnection connection, IMapper mapper) + public LendController(IModel repo, IMapper mapper) { - _repository = new LendModel(connection); + _repository = (LendModel)repo; _mapper = mapper; } diff --git a/DTOs/LendRead.cs b/DTOs/LendRead.cs index 5813213..0d39ee9 100644 --- a/DTOs/LendRead.cs +++ b/DTOs/LendRead.cs @@ -7,6 +7,5 @@ namespace BuecherwurmAPI.DTOs public int ItemId { get; set;} public DateTime ReturnDate { get; set; } public string Customer { get; set; } - public bool Returned { get; set; } } } \ No newline at end of file diff --git a/LongWormMemory.db b/LongWormMemory.db index 4b1deb5..c665918 100644 Binary files a/LongWormMemory.db and b/LongWormMemory.db differ diff --git a/Models/ItemModel.cs b/Models/ItemModel.cs index f2ef1b1..3a578e1 100644 --- a/Models/ItemModel.cs +++ b/Models/ItemModel.cs @@ -6,7 +6,7 @@ using Microsoft.VisualBasic.CompilerServices; namespace BuecherwurmAPI.Models { - internal class ItemModel : IItemRepo + internal class ItemModel : IModel { private SqliteConnection _dbConnection; diff --git a/Models/LendModel.cs b/Models/LendModel.cs index 014ac36..80076f4 100644 --- a/Models/LendModel.cs +++ b/Models/LendModel.cs @@ -10,9 +10,11 @@ namespace BuecherwurmAPI.Models { public SqliteConnection _dbConnection; - public LendModel(SqliteConnection connection) + public LendModel() { - _dbConnection = connection; + var connectionBuilder = new SqliteConnectionStringBuilder {DataSource = "LongWormMemory.db"}; + _dbConnection = new SqliteConnection(connectionBuilder.ConnectionString); + _dbConnection.Open(); } public bool IdExits(string table, long id) diff --git a/Startup.cs b/Startup.cs index c17f544..33779c4 100644 --- a/Startup.cs +++ b/Startup.cs @@ -33,6 +33,7 @@ namespace BuecherwurmAPI // It takes an interface and a specific implementation. // That allows to swap the implementation easily. services.AddScoped(); + services.AddScoped(); services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); }