diff --git a/src/WorkFlow.Application/Contracts/Repositories/IProfileRepository.cs b/src/WorkFlow.Application/Contracts/Repositories/IProfileRepository.cs
index b9fb642..bbd5ad8 100644
--- a/src/WorkFlow.Application/Contracts/Repositories/IProfileRepository.cs
+++ b/src/WorkFlow.Application/Contracts/Repositories/IProfileRepository.cs
@@ -2,7 +2,20 @@
namespace WorkFlow.Application.Contracts.Repositories;
+///
+/// Repository implementation for retrieving entities from the database.
+///
public interface IProfileRepository
{
+ ///
+ /// Retrieves the associated with a given user ID by calling a database function.
+ ///
+ /// The unique identifier of the user whose profile is to be retrieved.
+ ///
+ /// A task that represents the asynchronous operation. The task result contains the object if found; otherwise, null.
+ ///
+ ///
+ /// Logs an error if no profile is found, or if multiple profiles are returned, indicating potential data issues.
+ ///
Task ReadAsync(int userId);
}
\ No newline at end of file
diff --git a/src/WorkFlow.Infrastructure/Repositories/ProfileRepository.cs b/src/WorkFlow.Infrastructure/Repositories/ProfileRepository.cs
index 2ceeed6..210f56a 100644
--- a/src/WorkFlow.Infrastructure/Repositories/ProfileRepository.cs
+++ b/src/WorkFlow.Infrastructure/Repositories/ProfileRepository.cs
@@ -5,18 +5,35 @@ using WorkFlow.Domain.Entities;
namespace WorkFlow.Infrastructure.Repositories;
+///
+/// Repository implementation for retrieving entities from the database.
+///
public class ProfileRepository : IProfileRepository
{
private readonly ILogger _logger;
-
private readonly WFDBContext _context;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The database context used for accessing profile data.
+ /// The logger instance used for logging repository operations.
public ProfileRepository(WFDBContext context, ILogger logger)
{
_logger = logger;
_context = context;
}
+ ///
+ /// Retrieves the associated with a given user ID by calling a database function.
+ ///
+ /// The unique identifier of the user whose profile is to be retrieved.
+ ///
+ /// A task that represents the asynchronous operation. The task result contains the object if found; otherwise, null.
+ ///
+ ///
+ /// Logs an error if no profile is found, or if multiple profiles are returned, indicating potential data issues.
+ ///
public async Task ReadAsync(int userId)
{
var profiles = await _context.Profiles
@@ -24,9 +41,13 @@ public class ProfileRepository : IProfileRepository
.ToListAsync();
if (profiles == null || profiles.Count == 0)
+ {
_logger.LogError("No profile record was found associated with user ID {userId}.", userId);
- else if (profiles.Count > 0)
+ }
+ else if (profiles.Count > 1)
+ {
_logger.LogError("Multiple profile records were found for user ID {userId}, which may indicate a data integrity issue.", userId);
+ }
return profiles?.FirstOrDefault();
}