diff --git a/Back/skydiveLogs-api.Business/AircraftService.cs b/Back/skydiveLogs-api.Business/AircraftService.cs index 586e994..49ce2b5 100644 --- a/Back/skydiveLogs-api.Business/AircraftService.cs +++ b/Back/skydiveLogs-api.Business/AircraftService.cs @@ -26,7 +26,7 @@ namespace skydiveLogs_api.Business public Aircraft GetAircraftById(int id) { - throw new NotImplementedException(); + return _aircraftRepository.GetAircraftById(id); } public IEnumerable GetAllAircrafts() diff --git a/Back/skydiveLogs-api.Business/DropZoneService.cs b/Back/skydiveLogs-api.Business/DropZoneService.cs index 2f064eb..79a5fdf 100644 --- a/Back/skydiveLogs-api.Business/DropZoneService.cs +++ b/Back/skydiveLogs-api.Business/DropZoneService.cs @@ -31,7 +31,7 @@ namespace skydiveLogs_api.Business public DropZone GetDzById(int id) { - throw new NotImplementedException(); + return _dropZoneRepository.GetDzById(id); } public void UpdateDz(int id, DropZone dropZone) diff --git a/Back/skydiveLogs-api.Business/JumpService.cs b/Back/skydiveLogs-api.Business/JumpService.cs index 55861f4..1c60531 100644 --- a/Back/skydiveLogs-api.Business/JumpService.cs +++ b/Back/skydiveLogs-api.Business/JumpService.cs @@ -31,7 +31,7 @@ namespace skydiveLogs_api.Business public Jump GetJumpById(int id) { - throw new NotImplementedException(); + return _jumpRepository.GetJumpById(id); } public void UpdateJump(int id, Jump jump) diff --git a/Back/skydiveLogs-api.Business/JumpTypeService.cs b/Back/skydiveLogs-api.Business/JumpTypeService.cs index e0cb75e..cd8ffb6 100644 --- a/Back/skydiveLogs-api.Business/JumpTypeService.cs +++ b/Back/skydiveLogs-api.Business/JumpTypeService.cs @@ -2,7 +2,6 @@ using skydiveLogs_api.Model; using System; using System.Collections.Generic; -using System.Text; using skydiveLogs_api.Data.Interface; namespace skydiveLogs_api.Business @@ -31,7 +30,7 @@ namespace skydiveLogs_api.Business public JumpType GetJumpTypeById(int id) { - throw new NotImplementedException(); + return _jumpTypeRepository.GetJumpTypeById(id); } public void UpdateJumpType(int id, JumpType value) diff --git a/Back/skydiveLogs-api.Data/AircraftRepository.cs b/Back/skydiveLogs-api.Data/AircraftRepository.cs index f61c4f6..c615c8a 100644 --- a/Back/skydiveLogs-api.Data/AircraftRepository.cs +++ b/Back/skydiveLogs-api.Data/AircraftRepository.cs @@ -6,6 +6,7 @@ using System.Text; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.IO; +using System.Linq; namespace skydiveLogs_api.Data { @@ -24,5 +25,20 @@ namespace skydiveLogs_api.Data 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>(); + result = tmp.SingleOrDefault(t => t.Id == id); + } + + return result; + } } } diff --git a/Back/skydiveLogs-api.Data/DropZoneRepository.cs b/Back/skydiveLogs-api.Data/DropZoneRepository.cs index 6e1ae5d..e65b92c 100644 --- a/Back/skydiveLogs-api.Data/DropZoneRepository.cs +++ b/Back/skydiveLogs-api.Data/DropZoneRepository.cs @@ -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>(); + result = tmp.SingleOrDefault(t => t.Id == id); + } + + return result; + } } } diff --git a/Back/skydiveLogs-api.Data/Interface/IAircraftRepository.cs b/Back/skydiveLogs-api.Data/Interface/IAircraftRepository.cs index a774629..0e02305 100644 --- a/Back/skydiveLogs-api.Data/Interface/IAircraftRepository.cs +++ b/Back/skydiveLogs-api.Data/Interface/IAircraftRepository.cs @@ -8,5 +8,6 @@ namespace skydiveLogs_api.Data.Interface public interface IAircraftRepository { IEnumerable GetAllAircrafts(); + Aircraft GetAircraftById(int id); } } diff --git a/Back/skydiveLogs-api.Data/Interface/IDropZoneRepository.cs b/Back/skydiveLogs-api.Data/Interface/IDropZoneRepository.cs index 207e7df..8d744df 100644 --- a/Back/skydiveLogs-api.Data/Interface/IDropZoneRepository.cs +++ b/Back/skydiveLogs-api.Data/Interface/IDropZoneRepository.cs @@ -8,5 +8,7 @@ namespace skydiveLogs_api.Data.Interface public interface IDropZoneRepository { IEnumerable GetAllDzs(); + + DropZone GetDzById(int id); } } diff --git a/Back/skydiveLogs-api.Data/Interface/IJumpRepository.cs b/Back/skydiveLogs-api.Data/Interface/IJumpRepository.cs index 1cc3307..bb1bfbd 100644 --- a/Back/skydiveLogs-api.Data/Interface/IJumpRepository.cs +++ b/Back/skydiveLogs-api.Data/Interface/IJumpRepository.cs @@ -8,5 +8,6 @@ namespace skydiveLogs_api.Data.Interface public interface IJumpRepository { IEnumerable GetAllJumps(); + Jump GetJumpById(int id); } } diff --git a/Back/skydiveLogs-api.Data/Interface/IJumpTypeRepository.cs b/Back/skydiveLogs-api.Data/Interface/IJumpTypeRepository.cs index b129274..7eb08f7 100644 --- a/Back/skydiveLogs-api.Data/Interface/IJumpTypeRepository.cs +++ b/Back/skydiveLogs-api.Data/Interface/IJumpTypeRepository.cs @@ -8,5 +8,6 @@ namespace skydiveLogs_api.Data.Interface public interface IJumpTypeRepository { IEnumerable GetAllJumpTypes(); + JumpType GetJumpTypeById(int id); } } diff --git a/Back/skydiveLogs-api.Data/JumpRepository.cs b/Back/skydiveLogs-api.Data/JumpRepository.cs index 90ff1d5..1d6c3b9 100644 --- a/Back/skydiveLogs-api.Data/JumpRepository.cs +++ b/Back/skydiveLogs-api.Data/JumpRepository.cs @@ -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>(); + result = tmp.SingleOrDefault(t => t.Id == id); + } + + return result; + } } } diff --git a/Back/skydiveLogs-api.Data/JumpTypeRepository.cs b/Back/skydiveLogs-api.Data/JumpTypeRepository.cs index f6d14f7..0839f9c 100644 --- a/Back/skydiveLogs-api.Data/JumpTypeRepository.cs +++ b/Back/skydiveLogs-api.Data/JumpTypeRepository.cs @@ -6,6 +6,7 @@ using skydiveLogs_api.Model; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.IO; +using System.Linq; namespace skydiveLogs_api.Data { @@ -24,5 +25,20 @@ namespace skydiveLogs_api.Data 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>(); + result = tmp.SingleOrDefault(t => t.Id == id); + } + + return result; + } } } diff --git a/Back/skydiveLogs-api/Controllers/AircraftController.cs b/Back/skydiveLogs-api/Controllers/AircraftController.cs index c5869aa..fe9adad 100644 --- a/Back/skydiveLogs-api/Controllers/AircraftController.cs +++ b/Back/skydiveLogs-api/Controllers/AircraftController.cs @@ -31,7 +31,6 @@ namespace skydiveLogs_api.Controllers } // GET: api/Aircraft/5 - //[HttpGet("{id}", Name = "Get")] [HttpGet("{id}")] public AircraftResp Get(int id) { diff --git a/Back/skydiveLogs-api/Controllers/DropZoneController.cs b/Back/skydiveLogs-api/Controllers/DropZoneController.cs index 45f4e7b..ab47490 100644 --- a/Back/skydiveLogs-api/Controllers/DropZoneController.cs +++ b/Back/skydiveLogs-api/Controllers/DropZoneController.cs @@ -32,7 +32,6 @@ namespace skydiveLogs_api.Controllers } // GET: api/DropZone/5 - //[HttpGet("{id}", Name = "Get")] [HttpGet("{id}")] public DropZoneResp Get(int id) { diff --git a/Back/skydiveLogs-api/Controllers/JumpController.cs b/Back/skydiveLogs-api/Controllers/JumpController.cs index 9c55e64..5adef89 100644 --- a/Back/skydiveLogs-api/Controllers/JumpController.cs +++ b/Back/skydiveLogs-api/Controllers/JumpController.cs @@ -31,7 +31,6 @@ namespace skydiveLogs_api.Controllers } // GET: api/Jump/5 - //[HttpGet("{id}", Name = "Get")] [HttpGet("{id}")] public JumpResp Get(int id) { diff --git a/Back/skydiveLogs-api/Controllers/JumpTypeController.cs b/Back/skydiveLogs-api/Controllers/JumpTypeController.cs index cec6c18..b9aade8 100644 --- a/Back/skydiveLogs-api/Controllers/JumpTypeController.cs +++ b/Back/skydiveLogs-api/Controllers/JumpTypeController.cs @@ -31,7 +31,6 @@ namespace skydiveLogs_api.Controllers } // GET: api/JumpType/5 - //[HttpGet("{id}", Name = "Get")] [HttpGet("{id}")] public JumpTypeResp Get(int id) {