feat(profile): implement ReadProfile query with MediatR
Added ReadProfile query and its handler using MediatR pattern to retrieve user profile by user ID via IProfileRepository.
This commit is contained in:
parent
b25d4eb028
commit
14f5c73d43
22
src/WorkFlow.Application/Profile/ReadProfile.cs
Normal file
22
src/WorkFlow.Application/Profile/ReadProfile.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using MediatR;
|
||||
using WorkFlow.Application.Contracts.Repositories;
|
||||
|
||||
namespace WorkFlow.Application.Profile;
|
||||
|
||||
public record ReadProfile(int UserId) : IRequest<Domain.Entities.Profile?>;
|
||||
|
||||
public class ReadProfileHandler : IRequestHandler<ReadProfile, Domain.Entities.Profile?>
|
||||
{
|
||||
private readonly IProfileRepository _repository;
|
||||
|
||||
public ReadProfileHandler(IProfileRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
public async Task<Domain.Entities.Profile?> Handle(ReadProfile request, CancellationToken cancellationToken)
|
||||
{
|
||||
var profile = await _repository.ReadAsync(request.UserId);
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DigitalData.Core.Application" Version="3.2.0" />
|
||||
<PackageReference Include="MediatR" Version="13.0.0" />
|
||||
<PackageReference Include="UserManager.Application" Version="3.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user