Reviewed-on: #6 Co-authored-by: sandre <perso@sebastienandre.com> Co-committed-by: sandre <perso@sebastienandre.com>
90 lines
4.6 KiB
C#
90 lines
4.6 KiB
C#
using LiteDB;
|
|
|
|
using skydiveLogs_api.Domain;
|
|
using skydiveLogs_api.Infrastructure.Interfaces;
|
|
|
|
namespace skydiveLogs_api.Infrastructure
|
|
{
|
|
public class LiteDbProvider : IDataProvider
|
|
{
|
|
#region Public Constructors
|
|
|
|
public LiteDbProvider(string connectionString)
|
|
{
|
|
_db = new LiteDatabase(connectionString);
|
|
|
|
BsonMapper.Global.Entity<Jump>().DbRef(x => x.JumpType, "JumpType");
|
|
BsonMapper.Global.Entity<Jump>().DbRef(x => x.Aircraft, "Aircraft");
|
|
BsonMapper.Global.Entity<Jump>().DbRef(x => x.DropZone, "DropZone");
|
|
BsonMapper.Global.Entity<Jump>().DbRef(x => x.Gear, "Gear");
|
|
BsonMapper.Global.Entity<Jump>().DbRef(x => x.User, "User");
|
|
|
|
BsonMapper.Global.Entity<UserImage>().DbRef(x => x.User, "User");
|
|
|
|
BsonMapper.Global.Entity<Gear>().DbRef(x => x.User, "User");
|
|
|
|
BsonMapper.Global.Entity<FavoriteDropZone>().DbRef(x => x.User, "User");
|
|
BsonMapper.Global.Entity<FavoriteDropZone>().DbRef(x => x.DropZone, "DropZone");
|
|
|
|
BsonMapper.Global.Entity<TunnelFlight>().DbRef(x => x.Tunnel, "DropZone");
|
|
BsonMapper.Global.Entity<TunnelFlight>().DbRef(x => x.JumpType, "JumpType");
|
|
BsonMapper.Global.Entity<TunnelFlight>().DbRef(x => x.User, "User");
|
|
|
|
BsonMapper.Global.Entity<StatsByAircraft>().DbRef(x => x.User, "User");
|
|
BsonMapper.Global.Entity<StatsByDz>().DbRef(x => x.User, "User");
|
|
BsonMapper.Global.Entity<StatsByGear>().DbRef(x => x.User, "User");
|
|
BsonMapper.Global.Entity<StatsByJumpType>().DbRef(x => x.User, "User");
|
|
BsonMapper.Global.Entity<StatsByYear>().DbRef(x => x.User, "User");
|
|
BsonMapper.Global.Entity<StatsForLastMonthByDz>().DbRef(x => x.User, "User");
|
|
BsonMapper.Global.Entity<StatsForLastMonthByJumpType>().DbRef(x => x.User, "User");
|
|
BsonMapper.Global.Entity<StatsForLastYearByDz>().DbRef(x => x.User, "User");
|
|
BsonMapper.Global.Entity<StatsForLastYearByJumpType>().DbRef(x => x.User, "User");
|
|
BsonMapper.Global.Entity<StatsByYearByJumpType>().DbRef(x => x.User, "User");
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
public void Close()
|
|
{
|
|
_db.Dispose();
|
|
}
|
|
|
|
public ILiteCollection<T> GetCollection<T>()
|
|
{
|
|
return _db.GetCollection<T>();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Public Properties
|
|
|
|
public ILiteCollection<Aircraft> CollOfAircraft => _db.GetCollection<Aircraft>();
|
|
public ILiteCollection<DropZone> CollOfDropZone => _db.GetCollection<DropZone>();
|
|
public ILiteCollection<FavoriteDropZone> CollOfFavoriteDropZone => _db.GetCollection<FavoriteDropZone>();
|
|
public ILiteCollection<Gear> CollOfGear => _db.GetCollection<Gear>();
|
|
public ILiteCollection<UserImage> CollOfImage => _db.GetCollection<UserImage>();
|
|
public ILiteCollection<Jump> CollOfJump => _db.GetCollection<Jump>();
|
|
public ILiteCollection<JumpType> CollOfJumpType => _db.GetCollection<JumpType>();
|
|
public ILiteCollection<User> CollOfUser => _db.GetCollection<User>();
|
|
public ILiteCollection<TunnelFlight> CollOfTunnelFlight => _db.GetCollection<TunnelFlight>();
|
|
public ILiteCollection<StatsByAircraft> CollOfStatsByAircraft => _db.GetCollection<StatsByAircraft>();
|
|
public ILiteCollection<StatsByDz> CollOfStatsByDz => _db.GetCollection<StatsByDz>();
|
|
public ILiteCollection<StatsByGear> CollOfStatsByGear => _db.GetCollection<StatsByGear>();
|
|
public ILiteCollection<StatsByJumpType> CollOfStatsByJumpType => _db.GetCollection<StatsByJumpType>();
|
|
public ILiteCollection<StatsByYear> CollOfStatsByYear => _db.GetCollection<StatsByYear>();
|
|
public ILiteCollection<StatsForLastMonthByDz> CollOfStatsForLastMonthByDz => _db.GetCollection<StatsForLastMonthByDz>();
|
|
public ILiteCollection<StatsForLastMonthByJumpType> CollOfStatsForLastMonthByJumpType => _db.GetCollection<StatsForLastMonthByJumpType>();
|
|
public ILiteCollection<StatsForLastYearByDz> CollOfStatsForLastYearByDz => _db.GetCollection<StatsForLastYearByDz>();
|
|
public ILiteCollection<StatsForLastYearByJumpType> CollOfStatsForLastYearByJumpType => _db.GetCollection<StatsForLastYearByJumpType>();
|
|
public ILiteCollection<StatsByYearByJumpType> CollOfStatsByYearByJumpType => _db.GetCollection<StatsByYearByJumpType>();
|
|
#endregion Public Properties
|
|
|
|
#region Private Fields
|
|
|
|
private readonly LiteDatabase _db;
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |