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 AircraftRepository : IAircraftRepository { public AircraftRepository(IDataProvider dataProvider) { _dataProvider = dataProvider; _col = _dataProvider.CollOfAircraft; } public IEnumerable GetAll() { return _col.FindAll().ToList(); } public Aircraft GetById(int id) { return _col.FindById(new BsonValue(id)); } public bool Update(Aircraft aircraft) { return _col.Update(aircraft); } public bool Add(Aircraft newAircraft) { var result = true; try { _col.Insert(newAircraft); } catch { result = false; } return result; } private readonly IDataProvider _dataProvider; private readonly ILiteCollection _col; } }