first commit
This commit is contained in:
38
External/Implementations/Litedb/UserConfigDataAccess.cs
vendored
Normal file
38
External/Implementations/Litedb/UserConfigDataAccess.cs
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
using MotoVaultPro.External.Interfaces;
|
||||
using MotoVaultPro.Models;
|
||||
using MotoVaultPro.Helper;
|
||||
|
||||
namespace MotoVaultPro.External.Implementations
|
||||
{
|
||||
public class UserConfigDataAccess : IUserConfigDataAccess
|
||||
{
|
||||
private ILiteDBHelper _liteDB { get; set; }
|
||||
private static string tableName = "userconfigrecords";
|
||||
public UserConfigDataAccess(ILiteDBHelper liteDB)
|
||||
{
|
||||
_liteDB = liteDB;
|
||||
}
|
||||
public UserConfigData GetUserConfig(int userId)
|
||||
{
|
||||
var db = _liteDB.GetLiteDB();
|
||||
var table = db.GetCollection<UserConfigData>(tableName);
|
||||
return table.FindById(userId);
|
||||
}
|
||||
public bool SaveUserConfig(UserConfigData userConfigData)
|
||||
{
|
||||
var db = _liteDB.GetLiteDB();
|
||||
var table = db.GetCollection<UserConfigData>(tableName);
|
||||
table.Upsert(userConfigData);
|
||||
db.Checkpoint();
|
||||
return true;
|
||||
}
|
||||
public bool DeleteUserConfig(int userId)
|
||||
{
|
||||
var db = _liteDB.GetLiteDB();
|
||||
var table = db.GetCollection<UserConfigData>(tableName);
|
||||
table.Delete(userId);
|
||||
db.Checkpoint();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user