Little test with AI + Add the equipment (#8)

Tests using local LLM AI to add comments in the C# files
For the flights tunnel, show the total to day/hours
For the jump, add the equipment (now just with the wingsuit)

Reviewed-on: #8
Co-authored-by: sandre <perso@sebastienandre.com>
Co-committed-by: sandre <perso@sebastienandre.com>
This commit was merged in pull request #8.
This commit is contained in:
2026-05-16 09:24:13 +00:00
committed by sandre
parent 0ebdbca549
commit ceed44f997
70 changed files with 12142 additions and 10444 deletions
@@ -1,9 +1,10 @@
using LiteDB;
using System;
using System.Collections.Generic;
using System.Linq;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.Infrastructure
{
@@ -11,6 +12,14 @@ 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 used for database access operations</param>
/// <remarks>
/// This constructor initializes the repository with a reference to the data provider
/// and sets up the collection for aircraft data operations.
/// </remarks>
public AircraftRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -21,6 +30,15 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new aircraft to the database.
/// </summary>
/// <param name="newAircraft">The aircraft instance to insert into the database</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new aircraft into the database using LiteDB.
/// If an exception occurs during insertion, the method returns 0.
/// </remarks>
public int Add(Aircraft newAircraft)
{
int result;
@@ -38,21 +56,55 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all aircraft from the database.
/// </summary>
/// <returns>An enumerable collection containing all aircraft instances stored in the database</returns>
/// <remarks>
/// Queries the aircraft collection and retrieves all records,
/// then converts the result to a List for enumeration.
/// </remarks>
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 to retrieve</param>
/// <returns>The aircraft instance if found, otherwise null</returns>
/// <remarks>
/// Searches the aircraft collection for a record with the specified ID
/// and returns the found aircraft or null if no match exists.
/// </remarks>
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 stored in the database</returns>
/// <remarks>
/// This method is not currently implemented and throws
/// a <see cref="NotImplementedException"/> when called.
/// </remarks>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Updates an existing aircraft in the database.
/// </summary>
/// <param name="aircraft">The aircraft instance containing the updated data</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/></returns>
/// <remarks>
/// Updates the aircraft record in the database with the provided aircraft instance.
/// The method returns the result of the underlying LiteDB update operation.
/// </remarks>
public bool Update(Aircraft aircraft)
{
return _col.Update(aircraft);
@@ -62,9 +114,16 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields
/// <summary>
/// The LiteDB collection for aircraft records.
/// </summary>
private readonly ILiteCollection<Aircraft> _col;
/// <summary>
/// The data provider used for database access operations.
/// </summary>
private readonly IDataProvider _dataProvider;
#endregion Private Fields
}
}
}
@@ -1,9 +1,10 @@
using LiteDB;
using System;
using System.Collections.Generic;
using System.Linq;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.Infrastructure
{
@@ -11,6 +12,15 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="DropZoneRepository"/> class.
/// </summary>
/// <param name="dataProvider">The data provider used for database access operations.</param>
/// <remarks>
/// This constructor initializes the repository with a reference to the data provider
/// and sets up the collection for drop zone data operations.
/// The data provider manages the underlying LiteDatabase connection.
/// </remarks>
public DropZoneRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -21,13 +31,23 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
public int Add(DropZone newDz)
/// <summary>
/// Adds a new drop zone to the database.
/// </summary>
/// <param name="newDropZone">The drop zone instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new drop zone into the database using LiteDB.
/// If an exception occurs during insertion, the method returns 0.
/// The returned value indicates the number of records affected by the insert operation.
/// </remarks>
public int Add(DropZone newDropZone)
{
int result;
try
{
var tmp = _col.Insert(newDz);
var tmp = _col.Insert(newDropZone);
result = tmp.AsInt32;
}
catch
@@ -38,33 +58,80 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all drop zones from the database.
/// </summary>
/// <returns>An enumerable collection containing all drop zone instances stored in the database.</returns>
/// <remarks>
/// Queries the drop zone collection and retrieves all records,
/// then converts the result to a List for enumeration.
/// Returns an empty list if no drop zones exist in the database.
/// </remarks>
public IEnumerable<DropZone> GetAll()
{
return _col.FindAll().ToList();
}
/// <summary>
/// Retrieves a drop zone by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the drop zone to retrieve.</param>
/// <returns>The drop zone instance if found, otherwise null.</returns>
/// <remarks>
/// Searches the drop zone collection for a record with the specified ID
/// and returns the found drop zone or null if no match exists.
/// Use <see cref="GetAll"/> to retrieve all drop zones or filter by criteria.
/// </remarks>
public DropZone GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of drop zones in the database.
/// </summary>
/// <returns>The total number of drop zones stored in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws
/// a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of all drop zones.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the count is requested.</exception>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
public bool Update(DropZone updatedDz)
/// <summary>
/// Updates an existing drop zone in the database.
/// </summary>
/// <param name="dropZone">The drop zone instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// Updates the drop zone record in the database with the provided drop zone instance.
/// The drop zone must have a valid ID to be updated.
/// The method returns the result of the underlying LiteDB update operation.
/// If the drop zone does not exist, the update operation will return 0.
/// </remarks>
public bool Update(DropZone dropZone)
{
return _col.Update(updatedDz);
return _col.Update(dropZone);
}
#endregion Public Methods
#region Private Fields
/// <summary>
/// The LiteDB collection for drop zone records.
/// </summary>
private readonly ILiteCollection<DropZone> _col;
/// <summary>
/// The data provider used for database access operations.
/// </summary>
private readonly IDataProvider _dataProvider;
#endregion Private Fields
}
}
}
@@ -1,8 +1,9 @@
using LiteDB;
using System;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure
{
@@ -10,6 +11,16 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="FavoriteDropZoneRepository"/> class.
/// </summary>
/// <param name="dataProvider">The data provider used for database access operations.</param>
/// <remarks>
/// This constructor initializes the repository with a reference to the data provider
/// and sets up the collection for favorite drop zone data operations.
/// The data provider manages the underlying LiteDatabase connection and provides
/// typed collection accessors for different entity types.
/// </remarks>
public FavoriteDropZoneRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -20,6 +31,16 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new favorite drop zone to the database.
/// </summary>
/// <param name="favoriteToAdd">The favorite drop zone instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new favorite drop zone into the database using LiteDB.
/// If an exception occurs during insertion, the method returns 0.
/// The returned value indicates the number of records affected by the insert operation.
/// </remarks>
public int Add(FavoriteDropZone favoriteToAdd)
{
int result;
@@ -37,11 +58,31 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Deletes favorite drop zone entries by drop zone ID and user ID.
/// </summary>
/// <param name="dropZoneId">The unique identifier of the drop zone to delete favorites for.</param>
/// <param name="userId">The unique identifier of the user whose favorites to delete.</param>
/// <returns>The number of rows affected. Returns 0 if the delete operation failed or no records matched.</returns>
/// <remarks>
/// Deletes all favorite drop zone records where both the drop zone ID and user ID match the provided values.
/// This operation is commonly used to remove a specific user's favorites for a particular drop zone.
/// </remarks>
public int Delete(int dropZoneId, int userId)
{
return _col.DeleteMany(d => d.DropZone.Id == dropZoneId && d.User.Id == userId);
}
/// <summary>
/// Retrieves all favorite drop zones for a specific user.
/// </summary>
/// <param name="user">The user whose favorite drop zones to retrieve.</param>
/// <returns>An enumerable collection containing all favorite drop zone instances belonging to the specified user.</returns>
/// <remarks>
/// Queries the favorite drop zone collection and retrieves all records where the user ID matches the provided user.
/// Each returned record includes navigation properties to the associated user and drop zone entities.
/// Returns an empty collection if the user has no favorite drop zones.
/// </remarks>
public IEnumerable<FavoriteDropZone> GetAll(User user)
{
return _col.Query()
@@ -49,33 +90,81 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves all favorite drop zones from the database.
/// </summary>
/// <returns>An enumerable collection containing all favorite drop zone instances in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve all favorite drop zones across all users in the system.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public IEnumerable<FavoriteDropZone> GetAll()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Retrieves a favorite drop zone by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the favorite drop zone to retrieve.</param>
/// <returns>The favorite drop zone instance if found, otherwise null.</returns>
/// <remarks>
/// Searches the favorite drop zone collection for a record with the specified ID.
/// This method currently returns null as it's not implemented with proper filtering by ID.
/// Implement this method to retrieve a specific favorite drop zone by its database ID.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when attempting to retrieve by ID.</exception>
public FavoriteDropZone GetById(int id)
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Gets the total count of favorite drop zones for a specific user.
/// </summary>
/// <param name="user">The user whose favorite drop zones to count.</param>
/// <returns>The total number of favorite drop zones for the specified user.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of favorite drop zones per user.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Updates an existing favorite drop zone in the database.
/// </summary>
/// <param name="updated">The favorite drop zone instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to update existing favorite drop zone records in the database.
/// Note: Favorite drop zones may not typically be updated; consider using Add for new favorites.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when attempting to update.</exception>
public bool Update(FavoriteDropZone updated)
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
#endregion Public Methods
#region Private Fields
/// <summary>
/// The LiteDB collection for favorite drop zone records.
/// </summary>
private readonly ILiteCollection<FavoriteDropZone> _col;
/// <summary>
/// The data provider used for database access operations.
/// </summary>
private readonly IDataProvider _dataProvider;
#endregion Private Fields
}
}
}
@@ -1,8 +1,9 @@
using LiteDB;
using System;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure
{
@@ -10,6 +11,16 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="GearRepository"/> class.
/// </summary>
/// <param name="dataProvider">The data provider used for database access operations.</param>
/// <remarks>
/// This constructor initializes the repository with a reference to the data provider
/// and sets up the collection for gear data operations.
/// The data provider manages the underlying LiteDatabase connection and provides
/// typed collection accessors for different entity types.
/// </remarks>
public GearRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -20,6 +31,17 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new gear item to the database.
/// </summary>
/// <param name="newGear">The gear instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new gear item into the database using LiteDB.
/// The gear item should have all required properties set before insertion.
/// If an exception occurs during insertion, the method returns 0.
/// The returned value indicates the number of records affected by the insert operation.
/// </remarks>
public int Add(Gear newGear)
{
int result;
@@ -37,11 +59,30 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all gear items from the database.
/// </summary>
/// <returns>An enumerable collection containing all gear instances stored in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve all gear records from the database, potentially filtered by user.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public IEnumerable<Gear> GetAll()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Retrieves all gear items for a specific user.
/// </summary>
/// <param name="user">The user whose gear items to retrieve.</param>
/// <returns>An enumerable collection containing all gear instances belonging to the specified user.</returns>
/// <remarks>
/// Queries the gear collection and retrieves all records where the user ID matches the provided user.
/// Each returned gear record includes navigation properties to the associated user entity.
/// Returns an empty collection if the user has no gear items.
/// </remarks>
public IEnumerable<Gear> GetAll(User user)
{
return _col.Include(x => x.User)
@@ -50,16 +91,46 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves a gear item by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the gear item to retrieve.</param>
/// <returns>The gear item instance if found, otherwise null.</returns>
/// <remarks>
/// Searches the gear collection for a record with the specified ID.
/// Returns null if no gear item with the matching ID is found in the database.
/// </remarks>
public Gear GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of gear items for a specific user.
/// </summary>
/// <param name="user">The user whose gear items to count.</param>
/// <returns>The total number of gear items for the specified user.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of gear items per user.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Updates an existing gear item in the database.
/// </summary>
/// <param name="updatedGear">The gear item instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// Updates the gear record in the database with the provided gear item instance.
/// The gear item must have a valid ID to be updated.
/// The method returns the result of the underlying LiteDB update operation.
/// If the gear item does not exist, the update operation will return 0.
/// </remarks>
public bool Update(Gear updatedGear)
{
return _col.Update(updatedGear);
@@ -69,9 +140,16 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields
/// <summary>
/// The LiteDB collection for gear records.
/// </summary>
private readonly ILiteCollection<Gear> _col;
/// <summary>
/// The data provider used for database access operations.
/// </summary>
private readonly IDataProvider _dataProvider;
#endregion Private Fields
}
}
}
@@ -1,8 +1,9 @@
using LiteDB;
using System;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure
{
@@ -10,6 +11,16 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="JumpRepository"/> class.
/// </summary>
/// <param name="dataProvider">The data provider used for database access operations.</param>
/// <remarks>
/// This constructor initializes the repository with a reference to the data provider
/// and sets up the collection for jump data operations.
/// The data provider manages the underlying LiteDatabase connection and provides
/// typed collection accessors for different entity types.
/// </remarks>
public JumpRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -20,6 +31,17 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new jump record to the database.
/// </summary>
/// <param name="newJump">The jump instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new jump record into the database using LiteDB.
/// The jump record should have all required properties set before insertion.
/// If an exception occurs during insertion, the method returns 0.
/// The returned value indicates the number of records affected by the insert operation.
/// </remarks>
public int Add(Jump newJump)
{
int result;
@@ -37,11 +59,31 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Deletes a jump record by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the jump to delete.</param>
/// <returns><see langword="true"/> if the deletion was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// Deletes the jump record with the specified ID from the database.
/// The method uses the <see cref="ILiteCollection{T}.Delete"/> method to remove the record.
/// </remarks>
public bool DeleteById(int id)
{
return _col.Delete(new BsonValue(id));
}
/// <summary>
/// Retrieves all jump records for a specific user.
/// </summary>
/// <param name="user">The user whose jump records to retrieve.</param>
/// <returns>An enumerable collection containing all jump records belonging to the specified user.</returns>
/// <remarks>
/// Queries the jump collection and retrieves all records where the user ID matches the provided user.
/// Each returned jump record includes navigation properties to the associated aircraft, drop zone,
/// gear, and jump type entities for eager loading.
/// Returns an empty collection if the user has no jump records.
/// </remarks>
public IEnumerable<Jump> GetAll(User user)
{
return _col.Include(x => x.Aircraft)
@@ -51,11 +93,32 @@ namespace skydiveLogs_api.Infrastructure
.Find(j => j.User.Id == user.Id);
}
/// <summary>
/// Retrieves all jump records from the database.
/// </summary>
/// <returns>An enumerable collection containing all jump records stored in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve all jump records from the database without filtering.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public IEnumerable<Jump> GetAll()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Retrieves a range of jump records for a specific user with pagination.
/// </summary>
/// <param name="user">The user whose jump records to retrieve.</param>
/// <param name="beginIndex">The starting index for pagination (inclusive).</param>
/// <param name="endIndex">The ending index for pagination (exclusive).</param>
/// <returns>An enumerable collection containing the requested range of jump records.</returns>
/// <remarks>
/// Retrieves a paginated range of jump records for the specified user, ordered by jump date in descending order.
/// Uses LiteDB query operators to limit and offset the results for efficient pagination.
/// Each jump record includes navigation properties to related entities.
/// </remarks>
public IEnumerable<Jump> GetBetweenIndex(User user, int beginIndex, int endIndex)
{
return _col.Include(x => x.Aircraft)
@@ -70,21 +133,60 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves a jump record by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the jump to retrieve.</param>
/// <returns>The jump record instance if found, otherwise null.</returns>
/// <remarks>
/// Searches the jump collection for a record with the specified ID.
/// Returns null if no jump record with the matching ID is found in the database.
/// </remarks>
public Jump GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of jump records for a specific user.
/// </summary>
/// <param name="user">The user whose jump records to count.</param>
/// <returns>The total number of jump records for the specified user.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of jump records per user.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public int GetCount(User user)
{
return _col.Count(j => j.User.Id == user.Id);
}
/// <summary>
/// Gets the total count of jump records in the database.
/// </summary>
/// <returns>The total number of jump records stored in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of all jump records.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Updates an existing jump record in the database.
/// </summary>
/// <param name="updatedJump">The jump record instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// Updates the jump record in the database with the provided jump record instance.
/// The jump record must have a valid ID to be updated.
/// The method returns the result of the underlying LiteDB update operation.
/// If the jump record does not exist, the update operation will return 0.
/// </remarks>
public bool Update(Jump updatedJump)
{
return _col.Update(updatedJump);
@@ -94,9 +196,16 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields
/// <summary>
/// The LiteDB collection for jump records.
/// </summary>
private readonly ILiteCollection<Jump> _col;
/// <summary>
/// The data provider used for database access operations.
/// </summary>
private readonly IDataProvider _dataProvider;
#endregion Private Fields
}
}
}
@@ -1,9 +1,10 @@
using LiteDB;
using System;
using System.Collections.Generic;
using System.Linq;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.Infrastructure
{
@@ -11,6 +12,16 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="JumpTypeRepository"/> class.
/// </summary>
/// <param name="dataProvider">The data provider used for database access operations.</param>
/// <remarks>
/// This constructor initializes the repository with a reference to the data provider
/// and sets up the collection for jump type data operations.
/// The data provider manages the underlying LiteDatabase connection and provides
/// typed collection accessors for different entity types.
/// </remarks>
public JumpTypeRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -21,6 +32,17 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new jump type to the database.
/// </summary>
/// <param name="newJumpType">The jump type instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new jump type into the database using LiteDB.
/// The jump type should have all required properties set before insertion.
/// If an exception occurs during insertion, the method returns 0.
/// The returned value indicates the number of records affected by the insert operation.
/// </remarks>
public int Add(JumpType newJumpType)
{
int result;
@@ -38,21 +60,59 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all jump types from the database.
/// </summary>
/// <returns>An enumerable collection containing all jump type instances stored in the database.</returns>
/// <remarks>
/// Queries the jump type collection and retrieves all records,
/// then converts the result to a List for enumeration.
/// Returns an empty list if no jump types exist in the database.
/// </remarks>
public IEnumerable<JumpType> GetAll()
{
return _col.FindAll().ToList();
}
/// <summary>
/// Retrieves a jump type by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the jump type to retrieve.</param>
/// <returns>The jump type instance if found, otherwise null.</returns>
/// <remarks>
/// Searches the jump type collection for a record with the specified ID.
/// Returns null if no jump type with the matching ID is found in the database.
/// </remarks>
public JumpType GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of jump types in the database.
/// </summary>
/// <returns>The total number of jump types stored in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of all jump type records in the database.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Updates an existing jump type in the database.
/// </summary>
/// <param name="updatedJumpType">The jump type instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// Updates the jump type record in the database with the provided jump type instance.
/// The jump type must have a valid ID to be updated.
/// The method returns the result of the underlying LiteDB update operation.
/// If the jump type does not exist, the update operation will return 0.
/// </remarks>
public bool Update(JumpType updatedJumpType)
{
return _col.Update(updatedJumpType);
@@ -62,9 +122,16 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields
/// <summary>
/// The LiteDB collection for jump type records.
/// </summary>
private readonly ILiteCollection<JumpType> _col;
/// <summary>
/// The data provider used for database access operations.
/// </summary>
private readonly IDataProvider _dataProvider;
#endregion Private Fields
}
}
}
@@ -10,6 +10,10 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="StatsByDzRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public StatsByDzRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -20,6 +24,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new collection of stats by drop zone to the database
/// </summary>
/// <param name="newStats">The collection of stats by drop zone instances to add</param>
/// <returns>The number of rows affected</returns>
public int Add(IEnumerable<StatsByDz> newStats)
{
int result = 0;
@@ -40,6 +49,11 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all stats by drop zone for a specific user
/// </summary>
/// <param name="user">The user whose stats by drop zone to retrieve</param>
/// <returns>A collection of stats by drop zone instances belonging to the user</returns>
public IEnumerable<StatsByDz> GetAll(User user)
{
return _col.Include(x => x.User)
@@ -48,6 +62,12 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Updates existing stats by drop zone in the database
/// </summary>
/// <param name="updatedStats">The stats by drop zone instances to update</param>
/// <param name="user">The user whose stats to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(IEnumerable<StatsByDz> updatedStats, User user)
{
Delete(user);
@@ -56,6 +76,11 @@ namespace skydiveLogs_api.Infrastructure
return tmp != 0;
}
/// <summary>
/// Deletes all stats by drop zone for a specific user
/// </summary>
/// <param name="user">The user whose stats by drop zone to delete</param>
/// <returns>True if the delete was successful, false otherwise</returns>
public bool Delete(User user)
{
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
@@ -71,4 +96,4 @@ namespace skydiveLogs_api.Infrastructure
#endregion Private Fields
}
}
}
@@ -10,6 +10,10 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="StatsByGearRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public StatsByGearRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -20,6 +24,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new collection of stats by gear to the database
/// </summary>
/// <param name="newStats">The collection of stats by gear instances to add</param>
/// <returns>The number of rows affected</returns>
public int Add(IEnumerable<StatsByGear> newStats)
{
int result = 0;
@@ -40,6 +49,11 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all stats by gear for a specific user
/// </summary>
/// <param name="user">The user whose stats by gear to retrieve</param>
/// <returns>A collection of stats by gear instances belonging to the user</returns>
public IEnumerable<StatsByGear> GetAll(User user)
{
return _col.Include(x => x.User)
@@ -48,6 +62,12 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Updates existing stats by gear in the database
/// </summary>
/// <param name="updatedStats">The stats by gear instances to update</param>
/// <param name="user">The user whose stats to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(IEnumerable<StatsByGear> updatedStats, User user)
{
Delete(user);
@@ -56,6 +76,11 @@ namespace skydiveLogs_api.Infrastructure
return tmp != 0;
}
/// <summary>
/// Deletes all stats by gear for a specific user
/// </summary>
/// <param name="user">The user whose stats by gear to delete</param>
/// <returns>True if the delete was successful, false otherwise</returns>
public bool Delete(User user)
{
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
@@ -71,4 +96,4 @@ namespace skydiveLogs_api.Infrastructure
#endregion Private Fields
}
}
}
@@ -1,9 +1,9 @@
using LiteDB;
using System;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure
{
@@ -21,6 +21,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new tunnel flight to the database.
/// </summary>
/// <param name="newTunnelFlight">The tunnel flight instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
public int Add(TunnelFlight newTunnelFlight)
{
int result;
@@ -38,11 +43,21 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Deletes a tunnel flight by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the tunnel flight to delete.</param>
/// <returns><see langword="true"/> if the deletion was successful; otherwise, <see langword="false"/>.</returns>
public bool DeleteById(int id)
{
return _col.Delete(new BsonValue(id));
}
/// <summary>
/// Retrieves all tunnel flights for a specific user.
/// </summary>
/// <param name="user">The user whose tunnel flight records to retrieve.</param>
/// <returns>An enumerable collection containing all tunnel flight records belonging to the specified user.</returns>
public IEnumerable<TunnelFlight> GetAll(User user)
{
return _col.Include(x => x.Tunnel)
@@ -50,11 +65,22 @@ namespace skydiveLogs_api.Infrastructure
.Find(j => j.User.Id == user.Id);
}
/// <summary>
/// Retrieves all tunnel flights from the database.
/// </summary>
/// <returns>An enumerable collection containing all tunnel flight records stored in the database.</returns>
public IEnumerable<TunnelFlight> GetAll()
{
throw new System.NotImplementedException();
}
/// <summary>
/// Retrieves a range of tunnel flights for a specific user with pagination.
/// </summary>
/// <param name="user">The user whose tunnel flight records to retrieve.</param>
/// <param name="beginIndex">The starting index for pagination (inclusive).</param>
/// <param name="endIndex">The ending index for pagination (exclusive).</param>
/// <returns>An enumerable collection containing the requested range of tunnel flight records.</returns>
public IEnumerable<TunnelFlight> GetBetweenIndex(User user, int beginIndex, int endIndex)
{
return _col.Include(x => x.Tunnel)
@@ -67,6 +93,13 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves a range of tunnel flights within a date range for a specific user.
/// </summary>
/// <param name="user">The user whose tunnel flight records to retrieve.</param>
/// <param name="beginDate">The start of the date range (inclusive).</param>
/// <param name="endDate">The end of the date range (exclusive).</param>
/// <returns>An enumerable collection containing the requested range of tunnel flight records within the specified date range.</returns>
public IEnumerable<TunnelFlight> GetBetweenDate(User user, DateTime beginDate, DateTime endDate)
{
return _col.Include(x => x.Tunnel)
@@ -78,21 +111,40 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves a tunnel flight by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the tunnel flight to retrieve.</param>
/// <returns>The tunnel flight record instance if found, otherwise null.</returns>
public TunnelFlight GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of tunnel flights for a specific user.
/// </summary>
/// <param name="user">The user whose tunnel flight records to count.</param>
/// <returns>The total number of tunnel flight records for the specified user.</returns>
public int GetCount(User user)
{
return _col.Count(j => j.User.Id == user.Id);
}
/// <summary>
/// Gets the total count of tunnel flights in the database.
/// </summary>
/// <returns>The total number of tunnel flight records stored in the database.</returns>
public int GetCount()
{
throw new System.NotImplementedException();
}
/// <summary>
/// Updates an existing tunnel flight record in the database.
/// </summary>
/// <param name="updatedTunnelFlight">The tunnel flight instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
public bool Update(TunnelFlight updatedTunnelFlight)
{
return _col.Update(updatedTunnelFlight);
@@ -103,8 +155,9 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields
private readonly ILiteCollection<TunnelFlight> _col;
private readonly IDataProvider _dataProvider;
#endregion Private Fields
}
}
}
@@ -1,8 +1,9 @@
using LiteDB;
using System;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure
{
@@ -20,6 +21,17 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new user image to the database.
/// </summary>
/// <param name="newImage">The user image instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new user image into the database using LiteDB.
/// The user image should have all required properties set before insertion.
/// If an exception occurs during insertion, the method returns 0.
/// The returned value indicates the number of records affected by the insert operation.
/// </remarks>
public int Add(UserImage newImage)
{
int result;
@@ -37,11 +49,30 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all user images from the database.
/// </summary>
/// <returns>An enumerable collection containing all user image instances stored in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve all user image records from the database.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public IEnumerable<UserImage> GetAll()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Retrieves all user images for a specific user.
/// </summary>
/// <param name="user">The user whose image records to retrieve.</param>
/// <returns>An enumerable collection containing all user image instances belonging to the specified user.</returns>
/// <remarks>
/// Queries the user image collection and retrieves all records where the user ID matches the provided user.
/// Each returned image record includes navigation properties to the associated user entity.
/// Returns an empty collection if the user has no profile images.
/// </remarks>
public IEnumerable<UserImage> GetAll(User user)
{
return _col.Include(x => x.User)
@@ -50,16 +81,46 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves a user image by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the user image to retrieve.</param>
/// <returns>The user image instance if found, otherwise null.</returns>
/// <remarks>
/// Searches the user image collection for a record with the specified ID.
/// Returns null if no user image with the matching ID is found in the database.
/// </remarks>
public UserImage GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of user images for a specific user.
/// </summary>
/// <param name="user">The user whose image records to count.</param>
/// <returns>The total number of user image records for the specified user.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of user image records per user.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Updates an existing user image record in the database.
/// </summary>
/// <param name="image">The user image instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// Updates the user image record in the database with the provided image instance.
/// The user image must have a valid ID to be updated.
/// The method returns the result of the underlying LiteDB update operation.
/// If the user image does not exist, the update operation will return 0.
/// </remarks>
public bool Update(UserImage image)
{
return _col.Update(image);
@@ -70,8 +131,9 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields
private readonly ILiteCollection<UserImage> _col;
private readonly IDataProvider _dataProvider;
#endregion Private Fields
}
}
}
@@ -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="UserRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public UserRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -21,6 +25,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new user to the database
/// </summary>
/// <param name="newUser">The user instance to add</param>
/// <returns>The number of rows affected (0 if insert failed)</returns>
public int Add(User newUser)
{
int result;
@@ -38,26 +47,50 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all users from the database
/// </summary>
/// <returns>A collection of all user instances</returns>
public IEnumerable<User> GetAll()
{
throw new NotImplementedException();
}
/// <summary>
/// Retrieves a user by its unique identifier
/// </summary>
/// <param name="id">The unique identifier of the user</param>
/// <returns>The user instance or null if not found</returns>
public User GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Retrieves a user by their login credentials
/// </summary>
/// <param name="login">The user's login</param>
/// <param name="password">The user's password</param>
/// <returns>The user instance or null if not found</returns>
public User GetByLogin(string login, string password)
{
return _col.FindOne(u => u.Login == login && u.Password == password);
}
/// <summary>
/// Gets the total count of users in the database
/// </summary>
/// <returns>The total number of users</returns>
public int GetCount()
{
throw new System.NotImplementedException();
}
/// <summary>
/// Updates an existing user in the database
/// </summary>
/// <param name="updated">The user instance to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(User updated)
{
throw new NotImplementedException();
@@ -72,4 +105,4 @@ namespace skydiveLogs_api.Infrastructure
#endregion Private Fields
}
}
}