Add the method "Get*ById" in the stack Business
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -24,5 +25,20 @@ namespace skydiveLogs_api.Data
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public DropZone GetDzById(int id)
|
||||
{
|
||||
DropZone result;
|
||||
|
||||
using (StreamReader file = File.OpenText(@"Data/DropZone.json"))
|
||||
using (JsonTextReader reader = new JsonTextReader(file))
|
||||
{
|
||||
var jsonResult = (JArray)JToken.ReadFrom(reader);
|
||||
var tmp = jsonResult.ToObject<IEnumerable<DropZone>>();
|
||||
result = tmp.SingleOrDefault(t => t.Id == id);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user