Comments added by AI
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user