From e21ab458b198d05ca46441dfb6d0b0d7e5e04c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20ANDRE?= Date: Fri, 18 Aug 2023 09:52:28 +0200 Subject: [PATCH] Add the feature to update a jum type --- Back/skydiveLogs-api.Domain/CacheType.cs | 1 - .../Interfaces/IJumpTypeService.cs | 2 +- .../JumpTypeService.cs | 19 ++++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Back/skydiveLogs-api.Domain/CacheType.cs b/Back/skydiveLogs-api.Domain/CacheType.cs index fd2571a..45cef1f 100644 --- a/Back/skydiveLogs-api.Domain/CacheType.cs +++ b/Back/skydiveLogs-api.Domain/CacheType.cs @@ -4,7 +4,6 @@ { Gear, JumpType, - TunnelJumpType, Aircraft, DropZone, Tunnel diff --git a/Back/skydiveLogs-api.DomainBusiness/Interfaces/IJumpTypeService.cs b/Back/skydiveLogs-api.DomainBusiness/Interfaces/IJumpTypeService.cs index b2ee8fa..2a3564d 100644 --- a/Back/skydiveLogs-api.DomainBusiness/Interfaces/IJumpTypeService.cs +++ b/Back/skydiveLogs-api.DomainBusiness/Interfaces/IJumpTypeService.cs @@ -17,7 +17,7 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces JumpType GetJumpTypeById(int id); - void UpdateJumpType(int id, JumpType value); + bool UpdateJumpType(int id, JumpType value); #endregion Public Methods } diff --git a/Back/skydiveLogs-api.DomainBusiness/JumpTypeService.cs b/Back/skydiveLogs-api.DomainBusiness/JumpTypeService.cs index a3fd851..94164de 100644 --- a/Back/skydiveLogs-api.DomainBusiness/JumpTypeService.cs +++ b/Back/skydiveLogs-api.DomainBusiness/JumpTypeService.cs @@ -1,6 +1,7 @@ using skydiveLogs_api.Domain; using skydiveLogs_api.DomainBusiness.Interfaces; using skydiveLogs_api.DomainService.Repositories; +using skydiveLogs_api.Infrastructure; using System; using System.Collections.Generic; using System.Linq; @@ -45,13 +46,7 @@ namespace skydiveLogs_api.DomainBusiness 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); + return GetAllJumpTypes().Where(t => t.InTunnel); } public JumpType GetJumpTypeById(int id) @@ -60,9 +55,15 @@ namespace skydiveLogs_api.DomainBusiness return allJumpTypes.Single(g => g.Id == id); } - public void UpdateJumpType(int id, JumpType value) + public bool UpdateJumpType(int id, JumpType jumpType) { - throw new NotImplementedException(); + jumpType.Id = id; + + var result = _jumpTypeRepository.Update(jumpType); + if (result) + _cacheService.Delete(CacheType.JumpType); + + return result; } #endregion Public Methods