Files
SkydiveLogs/Back/skydiveLogs-api.Data/JumpRepository.cs
2019-09-26 15:31:17 +02:00

29 lines
759 B
C#

using System;
using System.Collections.Generic;
using System.Text;
using skydiveLogs_api.Data.Interface;
using skydiveLogs_api.Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
namespace skydiveLogs_api.Data
{
public class JumpRepository : IJumpRepository
{
public IEnumerable<Jump> GetAllJumps()
{
IEnumerable<Jump> result = new List<Jump>();
using (StreamReader file = File.OpenText(@"Data/Jump.json"))
using (JsonTextReader reader = new JsonTextReader(file))
{
var jsonResult = (JArray)JToken.ReadFrom(reader);
result = jsonResult.ToObject<IEnumerable<Jump>>();
}
return result;
}
}
}