Update the repository pattern
This commit is contained in:
@@ -11,21 +11,18 @@ namespace skydiveLogs_api.Data
|
||||
{
|
||||
public class DropZoneRepository : IDropZoneRepository
|
||||
{
|
||||
public IEnumerable<DropZone> GetAllDzs()
|
||||
public DropZoneRepository(IDataProvider dataProvider)
|
||||
{
|
||||
IEnumerable<DropZone> result = new List<DropZone>();
|
||||
|
||||
using (var db = new LiteDatabase(@".\Data\MyData.db"))
|
||||
{
|
||||
var col = db.GetCollection<DropZone>("DropZone");
|
||||
|
||||
result = col.FindAll().ToList();
|
||||
}
|
||||
|
||||
return result;
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.GetCollection<DropZone>();
|
||||
}
|
||||
|
||||
public DropZone GetDzById(int id)
|
||||
public IEnumerable<DropZone> GetAll()
|
||||
{
|
||||
return _col.FindAll().ToList();
|
||||
}
|
||||
|
||||
public DropZone GetById(int id)
|
||||
{
|
||||
DropZone result;
|
||||
|
||||
@@ -38,5 +35,9 @@ namespace skydiveLogs_api.Data
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
private readonly LiteCollection<DropZone> _col;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user