Add LiteDb in all repositories
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using LiteDB;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using skydiveLogs_api.Data.Interface;
|
||||
using skydiveLogs_api.Model;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Data
|
||||
{
|
||||
public class DropZoneRepository : IDropZoneRepository
|
||||
@@ -15,24 +15,11 @@ namespace skydiveLogs_api.Data
|
||||
{
|
||||
IEnumerable<DropZone> result = new List<DropZone>();
|
||||
|
||||
//using (StreamReader file = File.OpenText(@"Data/DropZone.json"))
|
||||
//using (JsonTextReader reader = new JsonTextReader(file))
|
||||
//{
|
||||
// var jsonResult = (JArray)JToken.ReadFrom(reader);
|
||||
// result = jsonResult.ToObject<IEnumerable<DropZone>>();
|
||||
//}
|
||||
|
||||
using (var db = new LiteDatabase(@".\Data\MyData.db"))
|
||||
{
|
||||
// Get a collection (or create, if doesn't exist)
|
||||
var col = db.GetCollection<DropZone>("DropZone");
|
||||
|
||||
result = col.FindAll().ToList();
|
||||
//foreach (var item in result)
|
||||
//{
|
||||
// item.Id = 0;
|
||||
// col.Insert(item);
|
||||
//}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -42,12 +29,11 @@ namespace skydiveLogs_api.Data
|
||||
{
|
||||
DropZone result;
|
||||
|
||||
using (StreamReader file = File.OpenText(@"Data/DropZone.json"))
|
||||
using (JsonTextReader reader = new JsonTextReader(file))
|
||||
using (var db = new LiteDatabase(@".\Data\MyData.db"))
|
||||
{
|
||||
var jsonResult = (JArray)JToken.ReadFrom(reader);
|
||||
var tmp = jsonResult.ToObject<IEnumerable<DropZone>>();
|
||||
result = tmp.SingleOrDefault(t => t.Id == id);
|
||||
var col = db.GetCollection<DropZone>("DropZone");
|
||||
|
||||
result = col.FindById(new BsonValue(id));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user