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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using skydiveLogs_api.Data.Interface;
|
||||
using skydiveLogs_api.Model;
|
||||
|
||||
namespace skydiveLogs_api.Data
|
||||
{
|
||||
public class DropZoneRepository : IDropZoneRepository
|
||||
{
|
||||
public IEnumerable<DropZone> GetAllDzs()
|
||||
{
|
||||
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>>();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using skydiveLogs_api.Model;
|
||||
|
||||
namespace skydiveLogs_api.Data.Interface
|
||||
{
|
||||
public interface IAircraftRepository
|
||||
{
|
||||
IEnumerable<Aircraft> GetAllAircrafts();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using skydiveLogs_api.Model;
|
||||
|
||||
namespace skydiveLogs_api.Data.Interface
|
||||
{
|
||||
public interface IDropZoneRepository
|
||||
{
|
||||
IEnumerable<DropZone> GetAllDzs();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using skydiveLogs_api.Model;
|
||||
|
||||
namespace skydiveLogs_api.Data.Interface
|
||||
{
|
||||
public interface IJumpRepository
|
||||
{
|
||||
IEnumerable<Jump> GetAllJumps();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using skydiveLogs_api.Model;
|
||||
|
||||
namespace skydiveLogs_api.Data.Interface
|
||||
{
|
||||
public interface IJumpTypeRepository
|
||||
{
|
||||
IEnumerable<JumpType> GetAllJumpTypes();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,27 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,27 @@
|
||||
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 JumpTypeRepository : IJumpTypeRepository
|
||||
{
|
||||
public IEnumerable<JumpType> GetAllJumpTypes()
|
||||
{
|
||||
IEnumerable<JumpType> result = new List<JumpType>();
|
||||
|
||||
using (StreamReader file = File.OpenText(@"Data/JumpType.json"))
|
||||
using (JsonTextReader reader = new JsonTextReader(file))
|
||||
{
|
||||
var jsonResult = (JArray)JToken.ReadFrom(reader);
|
||||
result = jsonResult.ToObject<IEnumerable<JumpType>>();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\skydiveLogs-api.Model\skydiveLogs-api.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user