Last active
June 27, 2022 22:23
-
-
Save DavidRogersDev/467b2fe878859b670aa7bea1a3f254b5 to your computer and use it in GitHub Desktop.
Gist for Medium Article - CreateNewUserCommandHandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CreateNewUserCommandHandler : IRequestHandler<CreateNewUserCommand, ValidateableResponse<ApiResponse<int>>> | |
{ | |
private readonly ILogger _logger; | |
public CreateNewUserCommandHandler(ILogger logger) | |
{ | |
_logger = logger; | |
} | |
public async Task<ValidateableResponse<ApiResponse<int>>> Handle(CreateNewUserCommand request, | |
CancellationToken cancellationToken) | |
{ | |
// normally there would be code here which calls a service to persist the new user. | |
// For demo purposes, I will just return the Id of 10 for the new imaginary user. | |
return await Task.FromResult( | |
new ValidateableResponse<ApiResponse<int>>( | |
new ApiResponse<int> | |
{ | |
Data = 10, | |
Outcome = OperationOutcome.SuccessfulOutcome | |
} | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment