Add comments by AI
This commit is contained in:
@@ -11,7 +11,7 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public TunnelFlightService(IJumpTypeService jumpTypeService,
|
||||
public TunnelFlightService(IJumpTypeService jumpTypeService,
|
||||
ITunnelFlightRepository tunnelFlightRepository,
|
||||
IDropZoneService dropZoneService,
|
||||
IIdentityService identityService)
|
||||
@@ -26,26 +26,51 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all tunnel flights.
|
||||
/// </summary>
|
||||
/// <returns>A collection of TunnelFlight entities containing all tunnel flights.</returns>
|
||||
public IEnumerable<TunnelFlight> GetAllTunnelFlights()
|
||||
{
|
||||
return _tunnelFlightRepository.GetAll(_identityService.ConnectedUser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a tunnel flight by its ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The tunnel flight ID to retrieve.</param>
|
||||
/// <returns>A TunnelFlight entity containing the tunnel flight details.</returns>
|
||||
public TunnelFlight GetTunnelFlightById(int id)
|
||||
{
|
||||
return _tunnelFlightRepository.GetById(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the total count of tunnel flights.
|
||||
/// </summary>
|
||||
/// <returns>The total number of tunnel flights.</returns>
|
||||
public int GetTunnelFlightCount()
|
||||
{
|
||||
return _tunnelFlightRepository.GetCount(_identityService.ConnectedUser);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a range of tunnel flights with pagination.
|
||||
/// </summary>
|
||||
/// <param name="beginIndex">The starting index for pagination.</param>
|
||||
/// <param name="endIndex">The ending index for pagination.</param>
|
||||
/// <returns>A collection of TunnelFlight entities containing the requested range.</returns>
|
||||
public IEnumerable<TunnelFlight> GetTunnelFlightsByIndexes(int beginIndex, int endIndex)
|
||||
{
|
||||
return _tunnelFlightRepository.GetBetweenIndex(_identityService.ConnectedUser, beginIndex, endIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves tunnel flights grouped by month within a date range.
|
||||
/// </summary>
|
||||
/// <param name="beginDate">The start date for grouping.</param>
|
||||
/// <param name="endDate">The end date for grouping.</param>
|
||||
/// <returns>A collection of Statistic entities grouped by month.</returns>
|
||||
public IEnumerable<Statistic> GetTunnelFlightGroupByMonth(string beginDate, string endDate)
|
||||
{
|
||||
var convertedBeginDate = Convert.ToDateTime(beginDate);
|
||||
@@ -69,6 +94,12 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
return results;
|
||||
}
|
||||
/// <summary>
|
||||
/// Retrieves tunnel flights filtered by date range.
|
||||
/// </summary>
|
||||
/// <param name="beginDate">The start date for filtering.</param>
|
||||
/// <param name="endDate">The end date for filtering.</param>
|
||||
/// <returns>A collection of TunnelFlight entities filtered by the specified date range.</returns>
|
||||
public IEnumerable<TunnelFlight> GetTunnelFlightByDates(string beginDate, string endDate)
|
||||
{
|
||||
var convertedBeginDate = Convert.ToDateTime(beginDate);
|
||||
@@ -76,7 +107,13 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
return _tunnelFlightRepository.GetBetweenDate(_identityService.ConnectedUser, convertedBeginDate, convertedEndDate);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new tunnel flight to the system.
|
||||
/// </summary>
|
||||
/// <param name="tunnelId">The tunnel ID to add the flight to.</param>
|
||||
/// <param name="jumpTypeId">The jump type ID for the flight.</param>
|
||||
/// <param name="newFlight">TunnelFlight entity containing the new flight data.</param>
|
||||
public void AddNewFlight(int tunnelId, int jumpTypeId, TunnelFlight newFlight)
|
||||
{
|
||||
var tmp = _dropZoneService.GetDzById(tunnelId);
|
||||
@@ -93,17 +130,25 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
var selectedJumpType = _jumpTypeService.GetJumpTypeById(jumpTypeId);
|
||||
|
||||
|
||||
newFlight.Tunnel = selectedTunnel;
|
||||
newFlight.JumpType = selectedJumpType;
|
||||
_tunnelFlightRepository.Add(newFlight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a tunnel flight by its ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The tunnel flight ID to delete.</param>
|
||||
public void DeleteTunnelFlightById(int id)
|
||||
{
|
||||
_tunnelFlightRepository.DeleteById(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates an existing tunnel flight.
|
||||
/// </summary>
|
||||
/// <param name="id">The tunnel flight ID to update.</param>
|
||||
/// <param name="updatedTunnelFlight">TunnelFlight entity containing the updated tunnel flight data.</param>
|
||||
public void UpdateTunnelFlight(int id, TunnelFlight updatedTunnelFlight)
|
||||
{
|
||||
var myTunnelFlight = GetTunnelFlightById(id);
|
||||
@@ -125,4 +170,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user