Add comment by AI

This commit is contained in:
2026-04-17 17:26:20 +02:00
parent 61ed4bc223
commit b03085acbe
7 changed files with 251 additions and 18 deletions
@@ -1,4 +1,4 @@
using LiteDB;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
@@ -11,6 +11,10 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="AircraftRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public AircraftRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -21,6 +25,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new aircraft to the database
/// </summary>
/// <param name="newAircraft">The aircraft instance to add</param>
/// <returns>The number of rows affected (0 if insert failed)</returns>
public int Add(Aircraft newAircraft)
{
int result;
@@ -38,21 +47,39 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all aircraft from the database
/// </summary>
/// <returns>A collection of all aircraft instances</returns>
public IEnumerable<Aircraft> GetAll()
{
return _col.FindAll().ToList();
}
/// <summary>
/// Retrieves an aircraft by its unique identifier
/// </summary>
/// <param name="id">The unique identifier of the aircraft</param>
/// <returns>The aircraft instance or null if not found</returns>
public Aircraft GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of aircraft in the database
/// </summary>
/// <returns>The total number of aircraft</returns>
public int GetCount()
{
throw new System.NotImplementedException();
}
/// <summary>
/// Updates an existing aircraft in the database
/// </summary>
/// <param name="aircraft">The aircraft instance to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(Aircraft aircraft)
{
return _col.Update(aircraft);
@@ -67,4 +94,4 @@ namespace skydiveLogs_api.Infrastructure
#endregion Private Fields
}
}
}