Add some update

Add a TODO for the ideas
This commit is contained in:
Sébastien ANDRE
2023-05-19 12:24:29 +02:00
parent e41e7a1fe4
commit 7856989866
12 changed files with 197 additions and 30 deletions

View File

@@ -11,6 +11,8 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
Tunnel GetTunnelById(int id);
void AddNewFlight(int tunnelId, TunnelFlight newFlight);
#endregion Public Methods
}
}

View File

@@ -12,9 +12,13 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Constructors
public TunnelService(IDropZoneRepository dropZoneRepository,
ITunnelFlightepository tunnelFlightRepository,
IDropZoneService dropZoneService,
ICacheService cacheService)
{
_dropZoneRepository = dropZoneRepository;
_dropZoneService = dropZoneService;
_tunnelFlightRepository = tunnelFlightRepository;
_cacheService = cacheService;
}
@@ -33,6 +37,28 @@ namespace skydiveLogs_api.DomainBusiness
return allTunnels.Single(g => g.Id == id);
}
public void AddNewFlight(int tunnelId, TunnelFlight newFlight)
{
var selectedTunnel = _dropZoneService.GetDzById(tunnelId)
.Single(t => new Tunnel
{
Id = t.Id,
Name = t.Name,
Website = t.Website,
Address = t.Address,
Email = t.Email,
Latitude = t.Latitude,
Longitude = t.Longitude
}); ;
newFlight.Tunnel = selectedTunnel;
_tunnelFlightRepository.Add(newFlight);
}
#endregion Public Methods
#region Private Methods
private IEnumerable<Tunnel> GetAllRefTunnels()
{
if (!_cacheService.Contains(CacheType.Tunnel))
@@ -54,13 +80,14 @@ namespace skydiveLogs_api.DomainBusiness
return _cacheService.Get<IEnumerable<Tunnel>>(CacheType.Tunnel);
}
#endregion Public Methods
#endregion Private Methods
#region Private Fields
private readonly ICacheService _cacheService;
private readonly IDropZoneService _dropZoneService;
private readonly IDropZoneRepository _dropZoneRepository;
private readonly ITunnelFlightepository _tunnelFlightRepository;
#endregion Private Fields
}