Files
SkydiveLogs/Back/skydiveLogs-api.Data/JumpRepository.cs
2020-03-19 21:33:09 +01:00

67 lines
1.5 KiB
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(int userId)
{
return _col.Include(x => x.Aircraft)
.Include(x => x.DropZone)
.Include(x => x.Gear)
.Include(x => x.JumpType)
.FindAll()
.Where(j => j.UserId == userId)
.ToList();
}
public Jump GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
public bool Add(Jump newJump)
{
var result = true;
try
{
_col.Insert(newJump);
}
catch
{
result = false;
}
return result;
}
public bool Update(Jump updatedJump)
{
throw new System.NotImplementedException();
}
public IEnumerable<Jump> GetAll()
{
throw new System.NotImplementedException();
}
private readonly IDataProvider _dataProvider;
private readonly ILiteCollection<Jump> _col;
}
}