Update ubout DataProvider
This commit is contained in:
@@ -14,7 +14,7 @@ namespace skydiveLogs_api.Data
|
||||
public AircraftRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.GetCollection<Aircraft>();
|
||||
_col = _dataProvider.CollOfAircraft;
|
||||
}
|
||||
|
||||
public IEnumerable<Aircraft> GetAll()
|
||||
|
||||
@@ -14,17 +14,23 @@ namespace skydiveLogs_api.Data
|
||||
public DropZoneRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.GetCollection<DropZone>();
|
||||
_col = _dataProvider.CollOfDropZone;
|
||||
}
|
||||
|
||||
public IEnumerable<DropZone> 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;
|
||||
|
||||
@@ -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<T> GetCollection<T>();
|
||||
|
||||
void Close();
|
||||
|
||||
LiteCollection<Aircraft> CollOfAircraft { get; }
|
||||
|
||||
LiteCollection<DropZone> CollOfDropZone { get; }
|
||||
|
||||
LiteCollection<Gear> CollOfGear { get; }
|
||||
|
||||
LiteCollection<JumpType> CollOfJumpType { get; }
|
||||
|
||||
LiteCollection<Jump> CollOfJump { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Aircraft> CollOfAircraft => _db.GetCollection<Aircraft>();
|
||||
|
||||
public LiteCollection<DropZone> CollOfDropZone => _db.GetCollection<DropZone>();
|
||||
|
||||
public LiteCollection<Gear> CollOfGear => _db.GetCollection<Gear>();
|
||||
|
||||
public LiteCollection<JumpType> CollOfJumpType => _db.GetCollection<JumpType>();
|
||||
|
||||
public LiteCollection<Jump> CollOfJump => _db.GetCollection<Jump>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user