Add the method "Get*ById" in the stack Business
This commit is contained in:
@@ -26,7 +26,7 @@ namespace skydiveLogs_api.Business
|
|||||||
|
|
||||||
public Aircraft GetAircraftById(int id)
|
public Aircraft GetAircraftById(int id)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return _aircraftRepository.GetAircraftById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Aircraft> GetAllAircrafts()
|
public IEnumerable<Aircraft> GetAllAircrafts()
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace skydiveLogs_api.Business
|
|||||||
|
|
||||||
public DropZone GetDzById(int id)
|
public DropZone GetDzById(int id)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return _dropZoneRepository.GetDzById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateDz(int id, DropZone dropZone)
|
public void UpdateDz(int id, DropZone dropZone)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace skydiveLogs_api.Business
|
|||||||
|
|
||||||
public Jump GetJumpById(int id)
|
public Jump GetJumpById(int id)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return _jumpRepository.GetJumpById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateJump(int id, Jump jump)
|
public void UpdateJump(int id, Jump jump)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using skydiveLogs_api.Model;
|
using skydiveLogs_api.Model;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using skydiveLogs_api.Data.Interface;
|
using skydiveLogs_api.Data.Interface;
|
||||||
|
|
||||||
namespace skydiveLogs_api.Business
|
namespace skydiveLogs_api.Business
|
||||||
@@ -31,7 +30,7 @@ namespace skydiveLogs_api.Business
|
|||||||
|
|
||||||
public JumpType GetJumpTypeById(int id)
|
public JumpType GetJumpTypeById(int id)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return _jumpTypeRepository.GetJumpTypeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateJumpType(int id, JumpType value)
|
public void UpdateJumpType(int id, JumpType value)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Text;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace skydiveLogs_api.Data
|
namespace skydiveLogs_api.Data
|
||||||
{
|
{
|
||||||
@@ -24,5 +25,20 @@ namespace skydiveLogs_api.Data
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Aircraft GetAircraftById(int id)
|
||||||
|
{
|
||||||
|
Aircraft result;
|
||||||
|
|
||||||
|
using (StreamReader file = File.OpenText(@"Data/Aircraft.json"))
|
||||||
|
using (JsonTextReader reader = new JsonTextReader(file))
|
||||||
|
{
|
||||||
|
var jsonResult = (JArray)JToken.ReadFrom(reader);
|
||||||
|
var tmp = jsonResult.ToObject<IEnumerable<Aircraft>>();
|
||||||
|
result = tmp.SingleOrDefault(t => t.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
@@ -24,5 +25,20 @@ namespace skydiveLogs_api.Data
|
|||||||
|
|
||||||
return result;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,5 +8,6 @@ namespace skydiveLogs_api.Data.Interface
|
|||||||
public interface IAircraftRepository
|
public interface IAircraftRepository
|
||||||
{
|
{
|
||||||
IEnumerable<Aircraft> GetAllAircrafts();
|
IEnumerable<Aircraft> GetAllAircrafts();
|
||||||
|
Aircraft GetAircraftById(int id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,5 +8,7 @@ namespace skydiveLogs_api.Data.Interface
|
|||||||
public interface IDropZoneRepository
|
public interface IDropZoneRepository
|
||||||
{
|
{
|
||||||
IEnumerable<DropZone> GetAllDzs();
|
IEnumerable<DropZone> GetAllDzs();
|
||||||
|
|
||||||
|
DropZone GetDzById(int id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,5 +8,6 @@ namespace skydiveLogs_api.Data.Interface
|
|||||||
public interface IJumpRepository
|
public interface IJumpRepository
|
||||||
{
|
{
|
||||||
IEnumerable<Jump> GetAllJumps();
|
IEnumerable<Jump> GetAllJumps();
|
||||||
|
Jump GetJumpById(int id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,5 +8,6 @@ namespace skydiveLogs_api.Data.Interface
|
|||||||
public interface IJumpTypeRepository
|
public interface IJumpTypeRepository
|
||||||
{
|
{
|
||||||
IEnumerable<JumpType> GetAllJumpTypes();
|
IEnumerable<JumpType> GetAllJumpTypes();
|
||||||
|
JumpType GetJumpTypeById(int id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using skydiveLogs_api.Data.Interface;
|
using skydiveLogs_api.Data.Interface;
|
||||||
using skydiveLogs_api.Model;
|
using skydiveLogs_api.Model;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace skydiveLogs_api.Data
|
namespace skydiveLogs_api.Data
|
||||||
{
|
{
|
||||||
@@ -24,5 +23,20 @@ namespace skydiveLogs_api.Data
|
|||||||
|
|
||||||
return result;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using skydiveLogs_api.Model;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace skydiveLogs_api.Data
|
namespace skydiveLogs_api.Data
|
||||||
{
|
{
|
||||||
@@ -24,5 +25,20 @@ namespace skydiveLogs_api.Data
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JumpType GetJumpTypeById(int id)
|
||||||
|
{
|
||||||
|
JumpType result;
|
||||||
|
|
||||||
|
using (StreamReader file = File.OpenText(@"Data/JumpType.json"))
|
||||||
|
using (JsonTextReader reader = new JsonTextReader(file))
|
||||||
|
{
|
||||||
|
var jsonResult = (JArray)JToken.ReadFrom(reader);
|
||||||
|
var tmp = jsonResult.ToObject<IEnumerable<JumpType>>();
|
||||||
|
result = tmp.SingleOrDefault(t => t.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ namespace skydiveLogs_api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/Aircraft/5
|
// GET: api/Aircraft/5
|
||||||
//[HttpGet("{id}", Name = "Get")]
|
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public AircraftResp Get(int id)
|
public AircraftResp Get(int id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ namespace skydiveLogs_api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/DropZone/5
|
// GET: api/DropZone/5
|
||||||
//[HttpGet("{id}", Name = "Get")]
|
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public DropZoneResp Get(int id)
|
public DropZoneResp Get(int id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ namespace skydiveLogs_api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/Jump/5
|
// GET: api/Jump/5
|
||||||
//[HttpGet("{id}", Name = "Get")]
|
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public JumpResp Get(int id)
|
public JumpResp Get(int id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ namespace skydiveLogs_api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/JumpType/5
|
// GET: api/JumpType/5
|
||||||
//[HttpGet("{id}", Name = "Get")]
|
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public JumpTypeResp Get(int id)
|
public JumpTypeResp Get(int id)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user