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