コード例 #1
0
		public static bool TrySearchForNames(Volunteer volunteer, ConsoleX consoleX)
		{
			// TODO Use Gender also to help with match.
			bool matchesFound = true;
			
			consoleX.WriteLine("Searching for matches on both First and Last name...");
			
			var table = Volunteers.GetByBothNames(volunteer.FirstName, volunteer.LastName, volunteer.Gender);
			
			if(table.Rows.Count == 0)
			{
				consoleX.WriteLine("No matched found on both First and Last name! Trying a wider search:");
				if(volunteer.Gender == GenderKind.Male)
				{
					consoleX.WriteLine("Searching for other brothers with same Last name...");
					table = Volunteers.GetByLastName(volunteer.LastName, volunteer.Gender);
				}
				else
				{
					consoleX.WriteLine("Searching for other sisters with same First OR Last name...");
					table = Volunteers.GetByEitherName(volunteer.FirstName, volunteer.LastName, volunteer.Gender);
				}
			}
			
			if(table.Rows.Count > 0)
			{
				consoleX.WriteLine(table.Rows.Count > 1 ? "The following matches where found:" : "The following match was found");
				consoleX.WriteDataTable(table, 15);
			}
			else
			{
				matchesFound = false;
				consoleX.WriteLine("No matches found!");
			}
			return matchesFound;
		}