feat: add ReadProfileAsync extension method for IMediator
This commit is contained in:
parent
dd4cd1b39e
commit
168a4b0791
@ -33,7 +33,7 @@ public class ProfileController : ControllerBase
|
|||||||
return Unauthorized("Failed to retrieve user identity.");
|
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);
|
return profile is null ? NotFound() : Ok(profile);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@ -46,3 +46,9 @@ public class ReadProfileHandler : IRequestHandler<ReadProfile, Domain.Entities.P
|
|||||||
return profile;
|
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));
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user