Rename directories and projects
This commit is contained in:
52
Back/skydiveLogs-api.Infrastructure/LiteDbProvider.cs
Normal file
52
Back/skydiveLogs-api.Infrastructure/LiteDbProvider.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using LiteDB;
|
||||
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class LiteDbProvider : IDataProvider
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
public ILiteCollection<T> GetCollection<T>()
|
||||
{
|
||||
return _db.GetCollection<T>();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
_db.Dispose();
|
||||
}
|
||||
|
||||
private readonly LiteDatabase _db;
|
||||
|
||||
public ILiteCollection<Aircraft> CollOfAircraft => _db.GetCollection<Aircraft>();
|
||||
|
||||
public ILiteCollection<DropZone> CollOfDropZone => _db.GetCollection<DropZone>();
|
||||
|
||||
public ILiteCollection<Gear> CollOfGear => _db.GetCollection<Gear>();
|
||||
|
||||
public ILiteCollection<JumpType> CollOfJumpType => _db.GetCollection<JumpType>();
|
||||
|
||||
public ILiteCollection<Jump> CollOfJump => _db.GetCollection<Jump>();
|
||||
|
||||
public ILiteCollection<User> CollOfUser => _db.GetCollection<User>();
|
||||
|
||||
public ILiteCollection<UserImage> CollOfImage => _db.GetCollection<UserImage>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user