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().DbRef(x => x.JumpType, "JumpType"); BsonMapper.Global.Entity().DbRef(x => x.Aircraft, "Aircraft"); BsonMapper.Global.Entity().DbRef(x => x.DropZone, "DropZone"); BsonMapper.Global.Entity().DbRef(x => x.Gear, "Gear"); BsonMapper.Global.Entity().DbRef(x => x.User, "User"); BsonMapper.Global.Entity().DbRef(x => x.User, "User"); BsonMapper.Global.Entity().DbRef(x => x.User, "User"); BsonMapper.Global.Entity().DbRef(x => x.User, "User"); BsonMapper.Global.Entity().DbRef(x => x.DropZone, "DropZone"); } #endregion Public Constructors #region Public Methods public void Close() { _db.Dispose(); } public ILiteCollection GetCollection() { return _db.GetCollection(); } #endregion Public Methods #region Public Properties public ILiteCollection CollOfAircraft => _db.GetCollection(); public ILiteCollection CollOfDropZone => _db.GetCollection(); public ILiteCollection CollOfFavoriteDropZone => _db.GetCollection(); public ILiteCollection CollOfGear => _db.GetCollection(); public ILiteCollection CollOfImage => _db.GetCollection(); public ILiteCollection CollOfJump => _db.GetCollection(); public ILiteCollection CollOfJumpType => _db.GetCollection(); public ILiteCollection CollOfUser => _db.GetCollection(); #endregion Public Properties #region Private Fields private readonly LiteDatabase _db; #endregion Private Fields } }