Add project files.
This commit is contained in:
70
ModVersionChecker/managers/litedb/AppConfigLiteDb.cs
Normal file
70
ModVersionChecker/managers/litedb/AppConfigLiteDb.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using ModVersionChecker.data.model;
|
||||
using ModVersionChecker.managers.interfaces;
|
||||
using ModVersionChecker.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModVersionChecker.managers.litedb
|
||||
{
|
||||
public class AppConfigLiteDb : LiteDb, IAppsManager
|
||||
{
|
||||
private string collection = LiteDb.APPS_COLLECTION;
|
||||
public List<AppConfig> Load()
|
||||
{
|
||||
var col = _db.GetCollection<AppConfig>(collection);
|
||||
return col.FindAll().ToList();
|
||||
}
|
||||
|
||||
public void Insert(AppConfig app)
|
||||
{
|
||||
var now = TimeUtils.GetUnixTimeMillis(null);
|
||||
app.CreatedAt = now;
|
||||
app.UpdatedAt = now;
|
||||
var col = _db.GetCollection<AppConfig>(collection);
|
||||
col.Insert(app);
|
||||
}
|
||||
|
||||
public void Update(AppConfig app)
|
||||
{
|
||||
var now = TimeUtils.GetUnixTimeMillis(null);
|
||||
app.UpdatedAt = now;
|
||||
var col = _db.GetCollection<AppConfig>(collection);
|
||||
col.Update(app);
|
||||
}
|
||||
|
||||
//public void Upsert(AppConfig app)
|
||||
//{
|
||||
// var now = TimeUtils.GetUnixTimeMillis(null);
|
||||
// app.UpdatedAt = now;
|
||||
// var col = _db.GetCollection<AppConfig>(collection);
|
||||
// if (string.IsNullOrEmpty(app.Id))
|
||||
// {
|
||||
// app.CreatedAt = now;
|
||||
// col.Insert(app);
|
||||
// }
|
||||
// col.Update(app);
|
||||
//}
|
||||
|
||||
public void Delete(string id)
|
||||
{
|
||||
var col = _db.GetCollection<AppConfig>(collection);
|
||||
col.Delete(id);
|
||||
}
|
||||
|
||||
public void Save(List<AppConfig> apps)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void UpdateStatus(AppConfig app, AppStatus status)
|
||||
{
|
||||
app.LastCheckedAt = TimeUtils.GetUnixTimeMillis(null);
|
||||
app.Status = status;
|
||||
var col = _db.GetCollection<AppConfig>(collection);
|
||||
col.Update(app);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user