feat: add ReadProfileAsync extension method for IMediator

This commit is contained in:
tekh 2025-07-25 17:50:38 +02:00
parent dd4cd1b39e
commit 168a4b0791
2 changed files with 7 additions and 1 deletions

View File

@ -33,7 +33,7 @@ public class ProfileController : ControllerBase
return Unauthorized("Failed to retrieve user identity.");
}
var profile = await _mediator.Send(new ReadProfile(UserId: userId));
var profile = await _mediator.ReadProfileAsync(userId);
return profile is null ? NotFound() : Ok(profile);
}
catch (Exception ex)

View File

@ -46,3 +46,9 @@ public class ReadProfileHandler : IRequestHandler<ReadProfile, Domain.Entities.P
return profile;
}
}
public static class ReadProfileExtensions
{
public static Task<Domain.Entities.Profile?> ReadProfileAsync(this IMediator mediator, int userId, bool includeObject = true)
=> mediator.Send(new ReadProfile(UserId: userId, IncludeObject: includeObject));
}