43 lines
956 B
C#
43 lines
956 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 AircraftRepository : IAircraftRepository
|
|
{
|
|
public IEnumerable<Aircraft> GetAll()
|
|
{
|
|
IEnumerable<Aircraft> result = new List<Aircraft>();
|
|
|
|
using (var db = new LiteDatabase(@".\Data\MyData.db"))
|
|
{
|
|
var col = db.GetCollection<Aircraft>("Aircraft");
|
|
|
|
result = col.FindAll().ToList();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public Aircraft GetById(int id)
|
|
{
|
|
Aircraft result;
|
|
|
|
using (var db = new LiteDatabase(@".\Data\MyData.db"))
|
|
{
|
|
var col = db.GetCollection<Aircraft>("Aircraft");
|
|
|
|
result = col.FindById(new BsonValue(id));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|