Files
SkydiveLogs/Back/skydiveLogs-api.Infrastructure/DropZoneRepository.cs
2021-03-12 18:01:15 +01:00

57 lines
1.2 KiB
C#

using System.Collections.Generic;
using System.Linq;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
namespace skydiveLogs_api.Infrastructure
{
public class DropZoneRepository : IDropZoneRepository
{
public DropZoneRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
_col = _dataProvider.CollOfDropZone;
}
public IEnumerable<DropZone> GetAll()
{
return _col.FindAll().ToList();
}
public DropZone GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
public bool Update(DropZone updatedDz)
{
return _col.Update(updatedDz);
}
public bool Add(DropZone newDz)
{
var result = true;
try
{
_col.Insert(newDz);
}
catch
{
result = false;
}
return result;
}
private readonly IDataProvider _dataProvider;
private readonly ILiteCollection<DropZone> _col;
}
}