Update the repository pattern

This commit is contained in:
Sébastien André
2019-11-10 19:31:55 +01:00
parent 3f1d648fa9
commit b95eedbf7c
19 changed files with 112 additions and 73 deletions

View File

@@ -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;
}
}