70 lines
1.5 KiB
C#
70 lines
1.5 KiB
C#
using LiteDB;
|
|
using skydiveLogs_api.Domain;
|
|
using skydiveLogs_api.DomainService.Repositories;
|
|
using skydiveLogs_api.Infrastructure.Interfaces;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace skydiveLogs_api.Infrastructure
|
|
{
|
|
public class DropZoneRepository : IDropZoneRepository
|
|
{
|
|
#region Public Constructors
|
|
|
|
public DropZoneRepository(IDataProvider dataProvider)
|
|
{
|
|
_dataProvider = dataProvider;
|
|
_col = _dataProvider.CollOfDropZone;
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
public int Add(DropZone newDz)
|
|
{
|
|
int result;
|
|
|
|
try
|
|
{
|
|
var tmp = _col.Insert(newDz);
|
|
result = tmp.AsInt32;
|
|
}
|
|
catch
|
|
{
|
|
result = 0;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public IEnumerable<DropZone> GetAll()
|
|
{
|
|
return _col.FindAll().ToList();
|
|
}
|
|
|
|
public DropZone GetById(int id)
|
|
{
|
|
return _col.FindById(new BsonValue(id));
|
|
}
|
|
|
|
public int GetCount()
|
|
{
|
|
throw new System.NotImplementedException();
|
|
}
|
|
|
|
public bool Update(DropZone updatedDz)
|
|
{
|
|
return _col.Update(updatedDz);
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Private Fields
|
|
|
|
private readonly ILiteCollection<DropZone> _col;
|
|
private readonly IDataProvider _dataProvider;
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |