Différencier Tunnel et TunnelFlight
This commit is contained in:
73
Back/skydiveLogs-api.DomainBusiness/TunnelFlightService.cs
Normal file
73
Back/skydiveLogs-api.DomainBusiness/TunnelFlightService.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.DomainBusiness
|
||||
{
|
||||
public class TunnelFlightService : ITunnelFlightService
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public TunnelFlightService(ITunnelFlightRepository tunnelFlightRepository,
|
||||
IDropZoneService dropZoneService,
|
||||
IIdentityService identityService)
|
||||
{
|
||||
_dropZoneService = dropZoneService;
|
||||
_identityService = identityService;
|
||||
_tunnelFlightRepository = tunnelFlightRepository;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public IEnumerable<TunnelFlight> GetAllTunnelFlights()
|
||||
{
|
||||
return _tunnelFlightRepository.GetAll(_identityService.ConnectedUser);
|
||||
}
|
||||
|
||||
public TunnelFlight GetTunnelFlightById(int id)
|
||||
{
|
||||
return _tunnelFlightRepository.GetById(id);
|
||||
}
|
||||
|
||||
public void AddNewFlight(int tunnelId, TunnelFlight newFlight)
|
||||
{
|
||||
var tmp = _dropZoneService.GetDzById(tunnelId);
|
||||
var selectedTunnel = new Tunnel
|
||||
{
|
||||
Id = tmp.Id,
|
||||
Name = tmp.Name,
|
||||
Website = tmp.Website,
|
||||
Address = tmp.Address,
|
||||
Email = tmp.Email,
|
||||
Latitude = tmp.Latitude,
|
||||
Longitude = tmp.Longitude
|
||||
};
|
||||
|
||||
newFlight.Tunnel = selectedTunnel;
|
||||
_tunnelFlightRepository.Add(newFlight);
|
||||
}
|
||||
|
||||
public int GetTunnelFlightCount()
|
||||
{
|
||||
return _tunnelFlightRepository.GetCount(_identityService.ConnectedUser);
|
||||
}
|
||||
|
||||
public IEnumerable<TunnelFlight> GetTunnelFlightsByIndexes(int beginIndex, int endIndex)
|
||||
{
|
||||
return _tunnelFlightRepository.GetBetweenIndex(_identityService.ConnectedUser, beginIndex, endIndex);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly IDropZoneService _dropZoneService;
|
||||
private readonly ITunnelFlightRepository _tunnelFlightRepository;
|
||||
private readonly IIdentityService _identityService;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user