44 lines
992 B
C#
44 lines
992 B
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
using LiteDB;
|
|
|
|
using skydiveLogs_api.Data.Interface;
|
|
using skydiveLogs_api.Model;
|
|
|
|
|
|
namespace skydiveLogs_api.Data
|
|
{
|
|
public class DropZoneRepository : IDropZoneRepository
|
|
{
|
|
public DropZoneRepository(IDataProvider dataProvider)
|
|
{
|
|
_dataProvider = dataProvider;
|
|
_col = _dataProvider.GetCollection<DropZone>();
|
|
}
|
|
|
|
public IEnumerable<DropZone> GetAll()
|
|
{
|
|
return _col.FindAll().ToList();
|
|
}
|
|
|
|
public DropZone GetById(int id)
|
|
{
|
|
DropZone result;
|
|
|
|
using (var db = new LiteDatabase(@".\Data\MyData.db"))
|
|
{
|
|
var col = db.GetCollection<DropZone>("DropZone");
|
|
|
|
result = col.FindById(new BsonValue(id));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
private readonly IDataProvider _dataProvider;
|
|
|
|
private readonly LiteCollection<DropZone> _col;
|
|
}
|
|
}
|