Created
July 15, 2019 08:01
-
-
Save ducmeit1/003e3c6844873237beec73d3f889e064 to your computer and use it in GitHub Desktop.
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 GetUserDetailHandler : IRequestHandler<GetUserDetailQuery, UserDto> | |
{ | |
private readonly IUserRepository _userRepository; | |
private readonly IUserMapper _userMapper; | |
public GetUserDetailHandler(IUserRepository userRepository, IUserMapper userMapper) { | |
_userRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository)); | |
_userMapper = userMapper ?? throw new ArgumentNullException(nameof(userMapper)); | |
} | |
public async Task<UserDto> Handle(GetUserDetailQuery request, CancellationToken cancellationToken) { | |
var user = await _userRepository.GetAsync(u => u.Id == request.Id) | |
if user == null { | |
return null | |
} | |
var userDto = _userMapper.MapUserDto(user); | |
return userDto; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment