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;
@@ -10,6 +10,10 @@ 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 to use for data access</param>
public JumpRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -20,6 +24,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new jump to the database
/// </summary>
/// <param name="newJump">The jump instance to add</param>
/// <returns>The number of rows affected (0 if insert failed)</returns>
public int Add(Jump newJump)
{
int result;
@@ -37,11 +46,21 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Deletes a jump by its unique identifier
/// </summary>
/// <param name="id">The unique identifier of the jump to delete</param>
/// <returns>True if the deletion was successful, false otherwise</returns>
public bool DeleteById(int id)
{
return _col.Delete(new BsonValue(id));
}
/// <summary>
/// Retrieves all jumps for a specific user
/// </summary>
/// <param name="user">The user whose jumps to retrieve</param>
/// <returns>A collection of jump instances belonging to the user</returns>
public IEnumerable<Jump> GetAll(User user)
{
return _col.Include(x => x.Aircraft)
@@ -51,11 +70,22 @@ namespace skydiveLogs_api.Infrastructure
.Find(j => j.User.Id == user.Id);
}
/// <summary>
/// Retrieves all jumps from the database
/// </summary>
/// <returns>A collection of all jump instances</returns>
public IEnumerable<Jump> GetAll()
{
throw new System.NotImplementedException();
}
/// <summary>
/// Retrieves a range of jumps for a specific user
/// </summary>
/// <param name="user">The user whose jumps to retrieve</param>
/// <param name="beginIndex">The starting index</param>
/// <param name="endIndex">The ending index</param>
/// <returns>A collection of jump instances</returns>
public IEnumerable<Jump> GetBetweenIndex(User user, int beginIndex, int endIndex)
{
return _col.Include(x => x.Aircraft)
@@ -70,21 +100,40 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves a jump by its unique identifier
/// </summary>
/// <param name="id">The unique identifier of the jump</param>
/// <returns>The jump instance or null if not found</returns>
public Jump GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of jumps for a specific user
/// </summary>
/// <param name="user">The user whose jumps to count</param>
/// <returns>The total number of jumps</returns>
public int GetCount(User user)
{
return _col.Count(j => j.User.Id == user.Id);
}
/// <summary>
/// Gets the total count of jumps in the database
/// </summary>
/// <returns>The total number of jumps</returns>
public int GetCount()
{
throw new System.NotImplementedException();
}
/// <summary>
/// Updates an existing jump in the database
/// </summary>
/// <param name="updatedJump">The jump instance to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(Jump updatedJump)
{
return _col.Update(updatedJump);
@@ -99,4 +148,4 @@ namespace skydiveLogs_api.Infrastructure
#endregion Private Fields
}
}
}