feat: add documentation comments

This commit is contained in:
tekh 2025-07-24 11:28:29 +02:00
parent 8c08beba4e
commit b25d4eb028
2 changed files with 36 additions and 2 deletions

View File

@ -2,7 +2,20 @@
namespace WorkFlow.Application.Contracts.Repositories;
/// <summary>
/// Repository implementation for retrieving <see cref="Profile"/> entities from the database.
/// </summary>
public interface IProfileRepository
{
/// <summary>
/// Retrieves the <see cref="Profile"/> associated with a given user ID by calling a database function.
/// </summary>
/// <param name="userId">The unique identifier of the user whose profile is to be retrieved.</param>
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the <see cref="Profile"/> object if found; otherwise, <c>null</c>.
/// </returns>
/// <remarks>
/// Logs an error if no profile is found, or if multiple profiles are returned, indicating potential data issues.
/// </remarks>
Task<Profile?> ReadAsync(int userId);
}

View File

@ -5,18 +5,35 @@ using WorkFlow.Domain.Entities;
namespace WorkFlow.Infrastructure.Repositories;
/// <summary>
/// Repository implementation for retrieving <see cref="Profile"/> entities from the database.
/// </summary>
public class ProfileRepository : IProfileRepository
{
private readonly ILogger<ProfileRepository> _logger;
private readonly WFDBContext _context;
/// <summary>
/// Initializes a new instance of the <see cref="ProfileRepository"/> class.
/// </summary>
/// <param name="context">The database context used for accessing profile data.</param>
/// <param name="logger">The logger instance used for logging repository operations.</param>
public ProfileRepository(WFDBContext context, ILogger<ProfileRepository> logger)
{
_logger = logger;
_context = context;
}
/// <summary>
/// Retrieves the <see cref="Profile"/> associated with a given user ID by calling a database function.
/// </summary>
/// <param name="userId">The unique identifier of the user whose profile is to be retrieved.</param>
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the <see cref="Profile"/> object if found; otherwise, <c>null</c>.
/// </returns>
/// <remarks>
/// Logs an error if no profile is found, or if multiple profiles are returned, indicating potential data issues.
/// </remarks>
public async Task<Profile?> 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();
}