public async Task <ValidationResult> ValidateAsync(GetAccountLegalEntitiesRequest item) { var validationResult = new ValidationResult(); if (string.IsNullOrEmpty(item.UserId)) { validationResult.AddError(nameof(item.UserId)); } if (string.IsNullOrEmpty(item.HashedAccountId)) { validationResult.AddError(nameof(item.HashedAccountId)); } if (!validationResult.IsValid()) { return(validationResult); } var result = await _employerAccountService.GetUserRoleOnAccount(item.HashedAccountId, item.UserId); if (result == null) { validationResult.IsUnauthorized = true; } return(validationResult); }
public async Task <GetUserAccountRoleResponse> Handle(GetUserAccountRoleQuery message) { var validationResult = _validator.Validate(message); if (!validationResult.IsValid()) { throw new InvalidRequestException(validationResult.ValidationDictionary); } var user = await _employerAccountService.GetUserRoleOnAccount(message.HashedAccountId, message.UserId); return(new GetUserAccountRoleResponse { User = user }); }