Little test with AI + Add the equipment #8

Merged
sandre merged 29 commits from feature/by-ai into master 2026-05-16 09:24:15 +00:00
2 changed files with 124 additions and 9 deletions
Showing only changes of commit 2663c70f8b - Show all commits
@@ -1,9 +1,9 @@
using LiteDB; using System;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
using System;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure namespace skydiveLogs_api.Infrastructure
{ {
@@ -21,6 +21,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods #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) public int Add(TunnelFlight newTunnelFlight)
{ {
int result; int result;
@@ -38,11 +43,21 @@ namespace skydiveLogs_api.Infrastructure
return result; 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) public bool DeleteById(int id)
{ {
return _col.Delete(new BsonValue(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) public IEnumerable<TunnelFlight> GetAll(User user)
{ {
return _col.Include(x => x.Tunnel) return _col.Include(x => x.Tunnel)
@@ -50,11 +65,22 @@ namespace skydiveLogs_api.Infrastructure
.Find(j => j.User.Id == user.Id); .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() public IEnumerable<TunnelFlight> GetAll()
{ {
throw new System.NotImplementedException(); 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) public IEnumerable<TunnelFlight> GetBetweenIndex(User user, int beginIndex, int endIndex)
{ {
return _col.Include(x => x.Tunnel) return _col.Include(x => x.Tunnel)
@@ -67,6 +93,13 @@ namespace skydiveLogs_api.Infrastructure
.ToList(); .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) public IEnumerable<TunnelFlight> GetBetweenDate(User user, DateTime beginDate, DateTime endDate)
{ {
return _col.Include(x => x.Tunnel) return _col.Include(x => x.Tunnel)
@@ -78,21 +111,40 @@ namespace skydiveLogs_api.Infrastructure
.ToList(); .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) public TunnelFlight GetById(int id)
{ {
return _col.FindById(new BsonValue(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) public int GetCount(User user)
{ {
return _col.Count(j => j.User.Id == user.Id); 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() public int GetCount()
{ {
throw new System.NotImplementedException(); 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) public bool Update(TunnelFlight updatedTunnelFlight)
{ {
return _col.Update(updatedTunnelFlight); return _col.Update(updatedTunnelFlight);
@@ -103,8 +155,9 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields #region Private Fields
private readonly ILiteCollection<TunnelFlight> _col; private readonly ILiteCollection<TunnelFlight> _col;
private readonly IDataProvider _dataProvider; private readonly IDataProvider _dataProvider;
#endregion Private Fields #endregion Private Fields
} }
} }
@@ -1,8 +1,9 @@
using LiteDB; using System;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure namespace skydiveLogs_api.Infrastructure
{ {
@@ -20,6 +21,17 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods #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) public int Add(UserImage newImage)
{ {
int result; int result;
@@ -37,11 +49,30 @@ namespace skydiveLogs_api.Infrastructure
return result; 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() 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) public IEnumerable<UserImage> GetAll(User user)
{ {
return _col.Include(x => x.User) return _col.Include(x => x.User)
@@ -50,16 +81,46 @@ namespace skydiveLogs_api.Infrastructure
.ToList(); .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) public UserImage GetById(int id)
{ {
return _col.FindById(new BsonValue(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() 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) public bool Update(UserImage image)
{ {
return _col.Update(image); return _col.Update(image);
@@ -70,8 +131,9 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields #region Private Fields
private readonly ILiteCollection<UserImage> _col; private readonly ILiteCollection<UserImage> _col;
private readonly IDataProvider _dataProvider; private readonly IDataProvider _dataProvider;
#endregion Private Fields #endregion Private Fields
} }
} }