diff --git a/Back/skydiveLogs-api.Data/AircraftRepository.cs b/Back/skydiveLogs-api.Data/AircraftRepository.cs index cfb27ca..22df8ef 100644 --- a/Back/skydiveLogs-api.Data/AircraftRepository.cs +++ b/Back/skydiveLogs-api.Data/AircraftRepository.cs @@ -14,7 +14,7 @@ namespace skydiveLogs_api.Data public AircraftRepository(IDataProvider dataProvider) { _dataProvider = dataProvider; - _col = _dataProvider.GetCollection(); + _col = _dataProvider.CollOfAircraft; } public IEnumerable GetAll() diff --git a/Back/skydiveLogs-api.Data/DropZoneRepository.cs b/Back/skydiveLogs-api.Data/DropZoneRepository.cs index 23f77e6..a8b6c43 100644 --- a/Back/skydiveLogs-api.Data/DropZoneRepository.cs +++ b/Back/skydiveLogs-api.Data/DropZoneRepository.cs @@ -14,17 +14,23 @@ namespace skydiveLogs_api.Data public DropZoneRepository(IDataProvider dataProvider) { _dataProvider = dataProvider; - _col = _dataProvider.GetCollection(); + _col = _dataProvider.CollOfDropZone; } public IEnumerable GetAll() { - return _col.FindAll().ToList(); + var results = _col.FindAll().ToList(); + _dataProvider.Close(); + + return results; } public DropZone GetById(int id) { - return _col.FindById(new BsonValue(id)); ; + var result = _col.FindById(new BsonValue(id)); + _dataProvider.Close(); + + return result; } private readonly IDataProvider _dataProvider; diff --git a/Back/skydiveLogs-api.Data/Interface/IDataProvider.cs b/Back/skydiveLogs-api.Data/Interface/IDataProvider.cs index b304134..a55ea2c 100644 --- a/Back/skydiveLogs-api.Data/Interface/IDataProvider.cs +++ b/Back/skydiveLogs-api.Data/Interface/IDataProvider.cs @@ -1,5 +1,7 @@ using LiteDB; +using skydiveLogs_api.Model; + namespace skydiveLogs_api.Data.Interface { @@ -8,5 +10,15 @@ namespace skydiveLogs_api.Data.Interface LiteCollection GetCollection(); void Close(); + + LiteCollection CollOfAircraft { get; } + + LiteCollection CollOfDropZone { get; } + + LiteCollection CollOfGear { get; } + + LiteCollection CollOfJumpType { get; } + + LiteCollection CollOfJump { get; } } } diff --git a/Back/skydiveLogs-api.Data/LiteDbProvider.cs b/Back/skydiveLogs-api.Data/LiteDbProvider.cs index e04f36a..bf41e31 100644 --- a/Back/skydiveLogs-api.Data/LiteDbProvider.cs +++ b/Back/skydiveLogs-api.Data/LiteDbProvider.cs @@ -1,7 +1,7 @@ using LiteDB; using skydiveLogs_api.Data.Interface; - +using skydiveLogs_api.Model; namespace skydiveLogs_api.Data { @@ -23,5 +23,15 @@ namespace skydiveLogs_api.Data } private readonly LiteDatabase _db; + + public LiteCollection CollOfAircraft => _db.GetCollection(); + + public LiteCollection CollOfDropZone => _db.GetCollection(); + + public LiteCollection CollOfGear => _db.GetCollection(); + + public LiteCollection CollOfJumpType => _db.GetCollection(); + + public LiteCollection CollOfJump => _db.GetCollection(); } }