feat: Lesevorgang für Benutzerprofil mittels MediatR und Repository implementiert
- ReadProfile-Request eingeführt, um Benutzerprofil anhand der UserId abzurufen - ReadProfileHandler hinzugefügt, der das Profil aus dem IProfileRepository liest - Asynchrone Verarbeitung mit Unterstützung für CancellationToken integriert
This commit is contained in:
@@ -28,17 +28,18 @@ public class ProfileRepository : IProfileRepository
|
||||
/// 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>
|
||||
/// <param name="cancel">Propagates notification that operations should be canceled.</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, CancellationToken cancel = default)
|
||||
{
|
||||
var profiles = await _context.Profiles
|
||||
.FromSqlRaw("SELECT * FROM FNMWF_GET_PROFILES ({0})", userId)
|
||||
.ToListAsync();
|
||||
.ToListAsync(cancel);
|
||||
|
||||
if (profiles == null || profiles.Count == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user