Implementation of repositories and return infos
This commit is contained in:
@@ -1,11 +1,28 @@
|
||||
using skydiveLogs_api.Data.Interface;
|
||||
using skydiveLogs_api.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.IO;
|
||||
|
||||
namespace skydiveLogs_api.Data
|
||||
{
|
||||
public class AircraftRepository : IAircraftRepository
|
||||
{
|
||||
public IEnumerable<Aircraft> GetAllAircrafts()
|
||||
{
|
||||
IEnumerable<Aircraft> result = new List<Aircraft>();
|
||||
|
||||
using (StreamReader file = File.OpenText(@"Data/Aircraft.json"))
|
||||
using (JsonTextReader reader = new JsonTextReader(file))
|
||||
{
|
||||
var jsonResult = (JArray)JToken.ReadFrom(reader);
|
||||
result = jsonResult.ToObject<IEnumerable<Aircraft>>();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user