Add the feature to update a jum type

This commit is contained in:
Sébastien ANDRE
2023-08-18 09:52:28 +02:00
parent b28bd7e7ff
commit e21ab458b1
3 changed files with 11 additions and 11 deletions

View File

@@ -4,7 +4,6 @@
{
Gear,
JumpType,
TunnelJumpType,
Aircraft,
DropZone,
Tunnel

View File

@@ -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
}

View File

@@ -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<JumpType> 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<IEnumerable<JumpType>>(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