diff --git a/Back/skydiveLogs-api.Infrastructure/TunnelFlightRepository.cs b/Back/skydiveLogs-api.Infrastructure/TunnelFlightRepository.cs index 15a92c6..58a1326 100644 --- a/Back/skydiveLogs-api.Infrastructure/TunnelFlightRepository.cs +++ b/Back/skydiveLogs-api.Infrastructure/TunnelFlightRepository.cs @@ -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 + /// + /// Adds a new tunnel flight to the database. + /// + /// The tunnel flight instance to insert into the database. + /// The number of rows affected. Returns 0 if the insert operation failed. public int Add(TunnelFlight newTunnelFlight) { int result; @@ -38,11 +43,21 @@ namespace skydiveLogs_api.Infrastructure return result; } + /// + /// Deletes a tunnel flight by its unique identifier. + /// + /// The unique identifier of the tunnel flight to delete. + /// if the deletion was successful; otherwise, . public bool DeleteById(int id) { return _col.Delete(new BsonValue(id)); } + /// + /// Retrieves all tunnel flights for a specific user. + /// + /// The user whose tunnel flight records to retrieve. + /// An enumerable collection containing all tunnel flight records belonging to the specified user. public IEnumerable GetAll(User user) { return _col.Include(x => x.Tunnel) @@ -50,11 +65,22 @@ namespace skydiveLogs_api.Infrastructure .Find(j => j.User.Id == user.Id); } + /// + /// Retrieves all tunnel flights from the database. + /// + /// An enumerable collection containing all tunnel flight records stored in the database. public IEnumerable GetAll() { throw new System.NotImplementedException(); } + /// + /// Retrieves a range of tunnel flights for a specific user with pagination. + /// + /// The user whose tunnel flight records to retrieve. + /// The starting index for pagination (inclusive). + /// The ending index for pagination (exclusive). + /// An enumerable collection containing the requested range of tunnel flight records. public IEnumerable GetBetweenIndex(User user, int beginIndex, int endIndex) { return _col.Include(x => x.Tunnel) @@ -67,6 +93,13 @@ namespace skydiveLogs_api.Infrastructure .ToList(); } + /// + /// Retrieves a range of tunnel flights within a date range for a specific user. + /// + /// The user whose tunnel flight records to retrieve. + /// The start of the date range (inclusive). + /// The end of the date range (exclusive). + /// An enumerable collection containing the requested range of tunnel flight records within the specified date range. public IEnumerable GetBetweenDate(User user, DateTime beginDate, DateTime endDate) { return _col.Include(x => x.Tunnel) @@ -78,21 +111,40 @@ namespace skydiveLogs_api.Infrastructure .ToList(); } + /// + /// Retrieves a tunnel flight by its unique identifier. + /// + /// The unique identifier of the tunnel flight to retrieve. + /// The tunnel flight record instance if found, otherwise null. public TunnelFlight GetById(int id) { return _col.FindById(new BsonValue(id)); } + /// + /// Gets the total count of tunnel flights for a specific user. + /// + /// The user whose tunnel flight records to count. + /// The total number of tunnel flight records for the specified user. public int GetCount(User user) { return _col.Count(j => j.User.Id == user.Id); } + /// + /// Gets the total count of tunnel flights in the database. + /// + /// The total number of tunnel flight records stored in the database. public int GetCount() { throw new System.NotImplementedException(); } + /// + /// Updates an existing tunnel flight record in the database. + /// + /// The tunnel flight instance containing the updated data. + /// if the update was successful; otherwise, . public bool Update(TunnelFlight updatedTunnelFlight) { return _col.Update(updatedTunnelFlight); @@ -103,8 +155,9 @@ namespace skydiveLogs_api.Infrastructure #region Private Fields private readonly ILiteCollection _col; + private readonly IDataProvider _dataProvider; #endregion Private Fields } -} \ No newline at end of file +} diff --git a/Back/skydiveLogs-api.Infrastructure/UserImageRepository.cs b/Back/skydiveLogs-api.Infrastructure/UserImageRepository.cs index 5e51941..611fc86 100644 --- a/Back/skydiveLogs-api.Infrastructure/UserImageRepository.cs +++ b/Back/skydiveLogs-api.Infrastructure/UserImageRepository.cs @@ -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 + /// + /// Adds a new user image to the database. + /// + /// The user image instance to insert into the database. + /// The number of rows affected. Returns 0 if the insert operation failed. + /// + /// 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. + /// public int Add(UserImage newImage) { int result; @@ -37,11 +49,30 @@ namespace skydiveLogs_api.Infrastructure return result; } + /// + /// Retrieves all user images from the database. + /// + /// An enumerable collection containing all user image instances stored in the database. + /// + /// This method is not currently implemented and throws a when called. + /// Implement this method to retrieve all user image records from the database. + /// + /// Thrown when the method is called. public IEnumerable GetAll() { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } + /// + /// Retrieves all user images for a specific user. + /// + /// The user whose image records to retrieve. + /// An enumerable collection containing all user image instances belonging to the specified user. + /// + /// 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. + /// public IEnumerable GetAll(User user) { return _col.Include(x => x.User) @@ -50,16 +81,46 @@ namespace skydiveLogs_api.Infrastructure .ToList(); } + /// + /// Retrieves a user image by its unique identifier. + /// + /// The unique identifier of the user image to retrieve. + /// The user image instance if found, otherwise null. + /// + /// 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. + /// public UserImage GetById(int id) { return _col.FindById(new BsonValue(id)); } + /// + /// Gets the total count of user images for a specific user. + /// + /// The user whose image records to count. + /// The total number of user image records for the specified user. + /// + /// This method is not currently implemented and throws a when called. + /// Implement this method to retrieve the count of user image records per user. + /// + /// Thrown when the method is called. public int GetCount() { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } + /// + /// Updates an existing user image record in the database. + /// + /// The user image instance containing the updated data. + /// if the update was successful; otherwise, . + /// + /// 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. + /// public bool Update(UserImage image) { return _col.Update(image); @@ -70,8 +131,9 @@ namespace skydiveLogs_api.Infrastructure #region Private Fields private readonly ILiteCollection _col; + private readonly IDataProvider _dataProvider; #endregion Private Fields } -} \ No newline at end of file +}