private void SearchUsers(string[] args) { if (args.Length < 2 || string.IsNullOrWhiteSpace(args[1])) { Console.WriteLine($"Please provide an e-mail address (partially) as argument\n"); return; } var users = _userReader.QueryAsync((user) => user.EmailAddress.Contains(args[1].Trim())) .GetAwaiter().GetResult().ToList(); if (users?.FirstOrDefault() == null) { Console.WriteLine($"No users found\n"); } else { users.ForEach(user => { Console.WriteLine($"{user.Id}: {user.EmailAddress} (status: {user.Status})"); }); } Console.WriteLine("\n"); }
public ConsoleApplication( IUserReader userReader, IUserWriter userWriter) { _userReader = userReader; _userWriter = userWriter; _userReader.QueryAsync(user => true).GetAwaiter().GetResult() .Select(user => user.EmailAddress) .ToList() .ForEach(emailAddress => _emailAddresses.Value.Add(emailAddress) ); }