44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using ModVersionChecker.data.model;
|
|
using ModVersionChecker.managers.interfaces;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ModVersionChecker.managers.litedb
|
|
{
|
|
public class SourcesLiteDb : LiteDb, ISourcesDefManager
|
|
{
|
|
private string collection = SOURCES_DEF_COLLECTION;
|
|
public List<SourceDef> List()
|
|
{
|
|
var col = _db.GetCollection<SourceDef>(collection);
|
|
return col.FindAll().ToList();
|
|
}
|
|
|
|
public SourceDef? GetById(string id)
|
|
{
|
|
var col = _db.GetCollection<SourceDef>(collection);
|
|
return col.FindOne(x => x.Id == id);
|
|
}
|
|
|
|
public void AddSourceDef(SourceDef sourceDef)
|
|
{
|
|
var col = _db.GetCollection<SourceDef>(collection);
|
|
col.Insert(sourceDef);
|
|
}
|
|
public void RemoveSourceDef(string id)
|
|
{
|
|
var col = _db.GetCollection<SourceDef>(collection);
|
|
col.Delete(id);
|
|
}
|
|
|
|
public void Save(SourceDef sourceDef)
|
|
{
|
|
var col = _db.GetCollection<SourceDef>(collection);
|
|
col.Upsert(sourceDef);
|
|
}
|
|
}
|
|
}
|