Rename directories and projects
This commit is contained in:
56
Back/skydiveLogs-api.Infrastructure/AircraftRepository.cs
Normal file
56
Back/skydiveLogs-api.Infrastructure/AircraftRepository.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
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<Aircraft> 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<Aircraft> _col;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user