public void ForListing_Everyone_Test()
    {
      var vh = new VoteHelper(false, true);

      vh.IneligibleToReceiveVotes(null, null).ShouldEqual(null);
      vh.IneligibleToReceiveVotes(Guid.Empty, false).ShouldEqual(Guid.Empty);

      var alreadyIneligibleGuid = Guid.NewGuid();

      vh.IneligibleToReceiveVotes(alreadyIneligibleGuid, true).ShouldEqual(alreadyIneligibleGuid);
      vh.IneligibleToReceiveVotes(alreadyIneligibleGuid, false).ShouldEqual(alreadyIneligibleGuid);

      vh.IneligibleToReceiveVotes(Guid.Empty, true).ShouldEqual(Guid.Empty);
      vh.IneligibleToReceiveVotes(Guid.Empty, false).ShouldEqual(Guid.Empty);
    }
    public void ForBallot_TieBreak_Test()
    {
      var vh = new VoteHelper(true, false);

      vh.IneligibleToReceiveVotes(null, null).ShouldEqual(IneligibleReasonEnum.Ineligible_Not_in_TieBreak);
      vh.IneligibleToReceiveVotes(Guid.Empty, false).ShouldEqual(IneligibleReasonEnum.Ineligible_Not_in_TieBreak);

      var alreadyIneligibleGuid = Guid.NewGuid();

      vh.IneligibleToReceiveVotes(alreadyIneligibleGuid, true).ShouldEqual(alreadyIneligibleGuid);
      vh.IneligibleToReceiveVotes(alreadyIneligibleGuid, false).ShouldEqual(alreadyIneligibleGuid);

      vh.IneligibleToReceiveVotes(Guid.Empty, true).ShouldEqual(Guid.Empty);
      vh.IneligibleToReceiveVotes(Guid.Empty, false).ShouldEqual(IneligibleReasonEnum.Ineligible_Not_in_TieBreak);
    }
    //private IQueryable<Person> People
    //{
    //  get { return _people; }
    //}

    public JsonResult Search(string nameToFind, bool includeMatches, bool forBallot)
    {
      const int max = 45;
      
      var parts = nameToFind.Split(new[] {' '}, 2, StringSplitOptions.RemoveEmptyEntries);

      var term1 = parts[0];
      var metaphone1 = term1.GenerateDoubleMetaphone().DefaultTo("_");

      string term2 = null;
      string metaphone2 = null;
      if (parts.Length > 1)
      {
        term2 = parts[1];
        metaphone2 = term2.GenerateDoubleMetaphone().DefaultTo("_");
      }

      var moreExactMatchesFound = new ObjectParameter("MoreExactMatchesFound", typeof (bool));

      var results = Db.SqlSearch(UserSession.CurrentElectionGuid, term1, term2, metaphone1, metaphone2, max,
                                 moreExactMatchesFound, null);
      var moreFound = moreExactMatchesFound.Value != null && (bool) moreExactMatchesFound.Value;

      var voteHelper = new VoteHelper(forBallot);

      return new
        {
          People = results
            .Select(p => new
              {
                Id = p.PersonId,
                Name = p.FullName,
                Ineligible = voteHelper.IneligibleToReceiveVotes(p.Ineligible, p.CanReceiveVotes),
                p.BestMatch,
                p.MatchType
              }),
          MoreFound = moreFound ? "More than {0} exact matches".FilledWith(max) : ""
        }
        .AsJsonResult();
    }