Add project files.
This commit is contained in:
43
ModVersionChecker/managers/litedb/SourcesLiteDb.cs
Normal file
43
ModVersionChecker/managers/litedb/SourcesLiteDb.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user