diff --git a/Controllers/ItemController.cs b/Controllers/ItemController.cs index 83506c0..f4974e0 100644 --- a/Controllers/ItemController.cs +++ b/Controllers/ItemController.cs @@ -14,7 +14,7 @@ namespace BuecherwurmAPI.Controllers { private readonly ItemModel _repository; - public ItemController(IModel repository) + public ItemController(IItem repository) { _repository = (ItemModel)repository; } @@ -50,7 +50,7 @@ namespace BuecherwurmAPI.Controllers // DELETE api/inventar/{id} - [HttpDelete("itemId")] + [HttpDelete("{itemId}")] public ActionResult> DeleteItem(long itemId) { var item = _repository.GetItemById(itemId); diff --git a/Controllers/LendController.cs b/Controllers/LendController.cs index 24f20b6..f599103 100644 --- a/Controllers/LendController.cs +++ b/Controllers/LendController.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading.Tasks; using AutoMapper; using BuecherwurmAPI.Models; -using BuecherwurmAPI.DTOs; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.JsonPatch; using Microsoft.Extensions.Logging; @@ -17,12 +16,12 @@ namespace BuecherwurmAPI.Controllers public class LendController : ControllerBase { private readonly LendModel _repository; - private readonly IMapper _mapper; + //private readonly IMapper _mapper; - public LendController(IModel repo, IMapper mapper) + public LendController(ILend repo) { _repository = (LendModel)repo; - _mapper = mapper; + //_mapper = mapper; } //GET api/leihvorgang diff --git a/LongWormMemory.db b/LongWormMemory.db index c665918..d001dc1 100644 Binary files a/LongWormMemory.db and b/LongWormMemory.db differ diff --git a/Models/Interfaces.cs b/Models/Interfaces.cs deleted file mode 100644 index 64a6026..0000000 --- a/Models/Interfaces.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Microsoft.Data.Sqlite; - -namespace BuecherwurmAPI.Models -{ - public interface IModel - { - - } -} \ No newline at end of file diff --git a/Models/ItemModel.cs b/Models/ItemModel.cs index 3a578e1..159b53b 100644 --- a/Models/ItemModel.cs +++ b/Models/ItemModel.cs @@ -6,7 +6,12 @@ using Microsoft.VisualBasic.CompilerServices; namespace BuecherwurmAPI.Models { - internal class ItemModel : IModel + public interface IItem + { + + } + + internal class ItemModel : IItem { private SqliteConnection _dbConnection; @@ -49,7 +54,7 @@ namespace BuecherwurmAPI.Models // using automatically disposes the command after completion using (var command = _dbConnection.CreateCommand()) { - command.CommandText = "SELECT FROM Items"; + command.CommandText = "SELECT * FROM Items"; var dataReader = command.ExecuteReader(); while (dataReader.Read()) @@ -71,13 +76,11 @@ namespace BuecherwurmAPI.Models using (var command = _dbConnection.CreateCommand()) { command.Parameters.Add(new SqliteParameter("@itemId", itemId)); - command.CommandText = "SELECT FROM Items WHERE Id = @itemId"; + command.CommandText = "SELECT * FROM Items WHERE ItemId = @itemId"; var dataReader = command.ExecuteReader(); while (dataReader.Read()) { - var returned = (long) dataReader["Returned"] == 1; - var item = new Item { ItemId = (long) dataReader["ItemId"], @@ -111,7 +114,6 @@ namespace BuecherwurmAPI.Models { using (var command = _dbConnection.CreateCommand()) { - command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = itemId; command.CommandText = "DELETE FROM Items WHERE ItemId = @itemId"; command.Parameters.Add(new SqliteParameter("@itemId", itemId)); command.ExecuteNonQuery(); diff --git a/Models/LendModel.cs b/Models/LendModel.cs index 1a0f5c1..3c2bba7 100644 --- a/Models/LendModel.cs +++ b/Models/LendModel.cs @@ -6,9 +6,15 @@ using Microsoft.VisualBasic.CompilerServices; namespace BuecherwurmAPI.Models { - internal class LendModel : IModel + + public interface ILend { - public SqliteConnection _dbConnection; + + } + + internal class LendModel : ILend + { + private SqliteConnection _dbConnection; public LendModel() { diff --git a/Profiles/LendProfile.cs b/Profiles/LendProfile.cs index 074931c..2d48c44 100644 --- a/Profiles/LendProfile.cs +++ b/Profiles/LendProfile.cs @@ -1,5 +1,4 @@ using AutoMapper; -using BuecherwurmAPI.DTOs; using BuecherwurmAPI.Models; namespace BuecherwurmAPI.Profiles @@ -8,7 +7,7 @@ namespace BuecherwurmAPI.Profiles { public LendProfile() { - CreateMap(); + CreateMap(); } } } \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index 33779c4..1fc2f81 100644 --- a/Startup.cs +++ b/Startup.cs @@ -32,8 +32,8 @@ namespace BuecherwurmAPI // Adds a service that is created once per connection. // It takes an interface and a specific implementation. // That allows to swap the implementation easily. - services.AddScoped(); - services.AddScoped(); + services.AddScoped(); + services.AddScoped(); services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); }