diff --git a/Back/skydiveLogs-api.Domain/CacheType.cs b/Back/skydiveLogs-api.Domain/CacheType.cs index 45cef1f..fd2571a 100644 --- a/Back/skydiveLogs-api.Domain/CacheType.cs +++ b/Back/skydiveLogs-api.Domain/CacheType.cs @@ -4,6 +4,7 @@ { Gear, JumpType, + TunnelJumpType, Aircraft, DropZone, Tunnel diff --git a/Back/skydiveLogs-api.Domain/JumpType.cs b/Back/skydiveLogs-api.Domain/JumpType.cs index 4c5bdf8..1f778f1 100644 --- a/Back/skydiveLogs-api.Domain/JumpType.cs +++ b/Back/skydiveLogs-api.Domain/JumpType.cs @@ -8,7 +8,7 @@ public string Name { get; set; } - public string InTunnel { get; set; } + public bool InTunnel { get; set; } #endregion Public Properties } diff --git a/Back/skydiveLogs-api.DomainBusiness/Interfaces/IJumpTypeService.cs b/Back/skydiveLogs-api.DomainBusiness/Interfaces/IJumpTypeService.cs index 94c68fe..b2ee8fa 100644 --- a/Back/skydiveLogs-api.DomainBusiness/Interfaces/IJumpTypeService.cs +++ b/Back/skydiveLogs-api.DomainBusiness/Interfaces/IJumpTypeService.cs @@ -13,6 +13,8 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces IEnumerable GetAllJumpTypes(); + IEnumerable GetJumpTypesForTunnel(); + JumpType GetJumpTypeById(int id); void UpdateJumpType(int id, JumpType value); diff --git a/Back/skydiveLogs-api.DomainBusiness/JumpTypeService.cs b/Back/skydiveLogs-api.DomainBusiness/JumpTypeService.cs index 1180fc2..a3fd851 100644 --- a/Back/skydiveLogs-api.DomainBusiness/JumpTypeService.cs +++ b/Back/skydiveLogs-api.DomainBusiness/JumpTypeService.cs @@ -43,6 +43,17 @@ namespace skydiveLogs_api.DomainBusiness return _cacheService.Get>(CacheType.JumpType); } + public IEnumerable GetJumpTypesForTunnel() + { + if (!_cacheService.Contains(CacheType.JumpType)) + { + var tmp = _jumpTypeRepository.GetAll().Where(t => t.InTunnel); + _cacheService.Put(CacheType.TunnelJumpType, tmp, 5 * 60 * 1000); + } + + return _cacheService.Get>(CacheType.TunnelJumpType); + } + public JumpType GetJumpTypeById(int id) { var allJumpTypes = GetAllJumpTypes(); diff --git a/Back/skydiveLogs-api/Controllers/JumpTypeController.cs b/Back/skydiveLogs-api/Controllers/JumpTypeController.cs index dd35321..0ffd57e 100644 --- a/Back/skydiveLogs-api/Controllers/JumpTypeController.cs +++ b/Back/skydiveLogs-api/Controllers/JumpTypeController.cs @@ -39,6 +39,15 @@ namespace skydiveLogs_api.Controllers var result = _jumpTypeService.GetAllJumpTypes(); return _mapper.Map>(result); } + + // GET: api/JumpType/tunnel + [HttpGet("tunnel")] + [EnableCors] + public IEnumerable GetForTunnel() + { + var result = _jumpTypeService.GetJumpTypesForTunnel(); + return _mapper.Map>(result); + } // GET: api/JumpType/5 [HttpGet("{id}")] diff --git a/Back/skydiveLogs-api/Init/jumpType.json b/Back/skydiveLogs-api/Init/jumpType.json index 6971cd9..60dc525 100644 --- a/Back/skydiveLogs-api/Init/jumpType.json +++ b/Back/skydiveLogs-api/Init/jumpType.json @@ -1,50 +1,62 @@ [ { "id": 1, - "name": "PAC" + "name": "PAC", + "InTunnel": false }, { "id": 2, - "name": "RW 4" + "name": "RW 4", + "InTunnel": true }, { "id": 3, - "name": "RW 8" + "name": "RW 8", + "InTunnel": true }, { "id": 4, - "name": "RW X" + "name": "RW X", + "InTunnel": false }, { "id": 5, - "name": "FreeFly" + "name": "FreeFly", + "InTunnel": true }, { "id": 6, - "name": "FreeStyle" + "name": "FreeStyle", + "InTunnel": false }, { "id": 7, - "name": "Canopy" + "name": "Canopy", + "InTunnel": false }, { "id": 8, - "name": "Track/Trace" + "name": "Track/Trace", + "InTunnel": false }, { "id": 9, - "name": "Wingsuit 1" + "name": "Wingsuit 1", + "InTunnel": true }, { "id": 10, - "name": "Wingsuit 2" + "name": "Wingsuit 2", + "InTunnel": false }, { "id": 11, - "name": "Wingsuit 3" + "name": "Wingsuit 3", + "InTunnel": false }, { "id": 13, - "name": "Landing accuracy" + "name": "Landing accuracy", + "InTunnel": false } ] \ No newline at end of file