Files
SkydiveLogs/Back/skydiveLogs-api.Data/JumpRepository.cs
2019-11-12 22:24:42 +01:00

51 lines
1011 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 JumpRepository : IJumpRepository
{
public JumpRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
_col = _dataProvider.CollOfJump;
}
public IEnumerable<Jump> GetAll()
{
return _col.FindAll().ToList();
}
public Jump GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
public bool AddJump(Jump newJump)
{
var result = true;
try
{
_col.Insert(newJump);
}
catch
{
result = false;
}
return result;
}
private readonly IDataProvider _dataProvider;
private readonly LiteCollection<Jump> _col;
}
}