Add the method "Get*ById" in the stack Business
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
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
|
||||
{
|
||||
@@ -24,5 +23,20 @@ namespace skydiveLogs_api.Data
|
||||
|
||||
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<IEnumerable<Jump>>();
|
||||
result = tmp.SingleOrDefault(t => t.Id == id);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user