Add comments by AI
This commit is contained in:
@@ -11,6 +11,11 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AircraftService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="aircraftRepository">The aircraft repository for data access.</param>
|
||||
/// <param name="cacheService">The cache service for caching operations.</param>
|
||||
public AircraftService(IAircraftRepository aircraftRepository,
|
||||
ICacheService cacheService)
|
||||
{
|
||||
@@ -22,23 +27,40 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new aircraft to the system.
|
||||
/// </summary>
|
||||
/// <param name="newAircraft">The Aircraft entity containing the data for the new aircraft.</param>
|
||||
public void AddNewAircraft(Aircraft newAircraft)
|
||||
{
|
||||
_aircraftRepository.Add(newAircraft);
|
||||
_cacheService.Delete(CacheType.Aircraft);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes an aircraft by its ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The aircraft ID to delete.</param>
|
||||
public void DeleteAircraftById(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves an aircraft by its ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The aircraft ID to retrieve.</param>
|
||||
/// <returns>An Aircraft entity containing the aircraft details.</returns>
|
||||
public Aircraft GetAircraftById(int id)
|
||||
{
|
||||
var allAircrafts = GetAllAircrafts();
|
||||
return allAircrafts.Single(g => g.Id == id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all aircrafts.
|
||||
/// </summary>
|
||||
/// <returns>A collection of Aircraft entities containing all aircraft data.</returns>
|
||||
public IEnumerable<Aircraft> GetAllAircrafts()
|
||||
{
|
||||
if (!_cacheService.Contains(CacheType.Aircraft))
|
||||
@@ -49,6 +71,13 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
return _cacheService.Get<IEnumerable<Aircraft>>(CacheType.Aircraft);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates an existing aircraft.
|
||||
/// </summary>
|
||||
/// <param name="id">The aircraft ID to update.</param>
|
||||
/// <param name="aircraft">Aircraft entity containing the updated aircraft data.</param>
|
||||
/// <param name="resetCache">Whether to reset the cache after update.</param>
|
||||
/// <returns>True if the update was successful, false otherwise.</returns>
|
||||
public bool UpdateAircraft(int id, Aircraft aircraft, bool resetCache = true)
|
||||
{
|
||||
aircraft.Id = id;
|
||||
@@ -69,4 +98,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user