feat: add documentation comments
This commit is contained in:
parent
8c08beba4e
commit
b25d4eb028
@ -2,7 +2,20 @@
|
|||||||
|
|
||||||
namespace WorkFlow.Application.Contracts.Repositories;
|
namespace WorkFlow.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Repository implementation for retrieving <see cref="Profile"/> entities from the database.
|
||||||
|
/// </summary>
|
||||||
public interface IProfileRepository
|
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);
|
Task<Profile?> ReadAsync(int userId);
|
||||||
}
|
}
|
||||||
@ -5,18 +5,35 @@ using WorkFlow.Domain.Entities;
|
|||||||
|
|
||||||
namespace WorkFlow.Infrastructure.Repositories;
|
namespace WorkFlow.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Repository implementation for retrieving <see cref="Profile"/> entities from the database.
|
||||||
|
/// </summary>
|
||||||
public class ProfileRepository : IProfileRepository
|
public class ProfileRepository : IProfileRepository
|
||||||
{
|
{
|
||||||
private readonly ILogger<ProfileRepository> _logger;
|
private readonly ILogger<ProfileRepository> _logger;
|
||||||
|
|
||||||
private readonly WFDBContext _context;
|
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)
|
public ProfileRepository(WFDBContext context, ILogger<ProfileRepository> logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_context = context;
|
_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)
|
public async Task<Profile?> ReadAsync(int userId)
|
||||||
{
|
{
|
||||||
var profiles = await _context.Profiles
|
var profiles = await _context.Profiles
|
||||||
@ -24,9 +41,13 @@ public class ProfileRepository : IProfileRepository
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
if (profiles == null || profiles.Count == 0)
|
if (profiles == null || profiles.Count == 0)
|
||||||
|
{
|
||||||
_logger.LogError("No profile record was found associated with user ID {userId}.", userId);
|
_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);
|
_logger.LogError("Multiple profile records were found for user ID {userId}, which may indicate a data integrity issue.", userId);
|
||||||
|
}
|
||||||
|
|
||||||
return profiles?.FirstOrDefault();
|
return profiles?.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user