Owneat Technical Guide main Help

Class UpdateUserCommandHandler

Namespace: Identity.Application.Requests.Handlers.User
Assembly: Identity.Application.dll

UpdateUserCommandHandler handles UpdateUserCommand requests and updates a user.

public sealed class UpdateUserCommandHandler : IRequestHandler<UpdateUserCommand, Result<UserResponse>>

Inheritance

object ← UpdateUserCommandHandler

Implements

IRequestHandler<UpdateUserCommand, Result<UserResponse\>\>

Inherited Members

object.Equals\(object?\), object.Equals\(object?, object?\), object.GetHashCode\(\), object.GetType\(\), object.ReferenceEquals\(object?, object?\), object.ToString\(\)

Constructors

UpdateUserCommandHandler\(IUserRepository, IUnitOfWork, IAuthorizationService, IHttpContextAccessor\)

Constructor takes dependencies for interacting with storage system and managing transactions.

public UpdateUserCommandHandler(IUserRepository userRepository, IUnitOfWork unitOfWork, IAuthorizationService authorizationService, IHttpContextAccessor httpContextAccessor)

Parameters

userRepository IUserRepository

Data access layer to user context.

unitOfWork IUnitOfWork

Unit of work that will sync changes on database through dbContext.

authorizationService IAuthorizationService

Service that will check the permissions to perform.

httpContextAccessor IHttpContextAccessor

Accessor that permit the handler to access the current HTTP context.

Methods

Handle\(UpdateUserCommand, CancellationToken\)

Handle method retrieves user, applies updates, and saves updated user to storage system.

public Task<Result<UserResponse>> Handle(UpdateUserCommand command, CancellationToken cancellationToken)

Parameters

command UpdateUserCommand

Identity.Application.Requests.Handlers.User.UpdateUserCommand received from the client from body request.

cancellationToken CancellationToken

Token that propagate method cancellation if needed.

Returns

Task <Result< UserResponse \>\>

The updated Identity.Application.Requests.Handlers.User.

Last modified: 21 May 2024