public void SkipDuplicates()
    {
      var fakeImportFile = new ImportFile();
      var fakes = new ImportFakes();
      var xmlDoc = new XmlDocument();
      var fakeDataContext = new FakeDataContext();

      xmlDoc.LoadXml("<Community><Person LName='Accorti' FName='Pónt' AKAName='Paul'></Person><Person LName='Accorti' FName='Pónt' AKAName='Paul'></Person></Community>");
      var model = new ImportV1Community(fakeDataContext, fakeImportFile, xmlDoc, fakes.People, fakes.AddPersonToDb, fakes.LogHelper);

      model.Process();

      fakes.People.Count.ShouldEqual(1);
      var people = fakes.People[0];
      people.LastName.ShouldEqual("Accorti");
      people.FirstName.ShouldEqual("Pónt");
      people.OtherNames.ShouldEqual("Paul");
    }
    public JsonResult Import(int rowId)
    {
      var currentElectionGuid = UserSession.CurrentElectionGuid;
      var file =
        Db.ImportFiles.SingleOrDefault(
          fi => fi.ElectionGuid == currentElectionGuid && fi.C_RowId == rowId);

      if (file == null)
      {
        throw new ApplicationException("File not found");
      }

      var xml = GetXmlDoc(file);

      if (xml == null || xml.DocumentElement == null)
      {
        throw new ApplicationException("Invalid Xml file");
      }

      var logHelper = new LogHelper();

      ImportV1Base importer;
      var currentPeople = Db.People.Where(p => p.ElectionGuid == currentElectionGuid).ToList();
      var personModel = new PeopleModel();


      switch (xml.DocumentElement.Name)
      {
        case "Community":
          importer = new ImportV1Community(Db, file, xml
                                           , currentPeople
                                           , delegate(Person person)
                                               {
                                                 personModel.SetCombinedInfoAtStart(person);
                                                 person.ElectionGuid = currentElectionGuid;
                                                 Db.People.Add(person);
                                               }
                                           , logHelper);
          break;
        case "Election":

          var currentElection = UserSession.CurrentElection;
          var currentLocation = UserSession.CurrentLocation;
          if (currentLocation == null)
          {
            currentLocation = Db.Locations.OrderBy(l => l.SortOrder).FirstOrDefault(l => l.ElectionGuid == currentElection.ElectionGuid);
            if (currentLocation == null)
            {
              throw new ApplicationException("An election must have a Location before importing.");
            }
          }

          EraseElectionContents(currentElection);

          importer = new ImportV1Election(Db, file, xml
                                          , currentElection
                                          , currentLocation
                                          , ballot => Db.Ballots.Add(ballot)
                                          , vote => Db.Votes.Add(vote)
                                          , currentPeople
                                          , person =>
                                              {
                                                personModel.SetCombinedInfoAtStart(person);
                                                Db.People.Add(person);
                                              }
                                          , summary => Db.ResultSummaries.Add(summary)
                                          , logHelper
            );
          break;
        default:
          throw new ApplicationException("Unexpected Xml file");
      }

      importer.Process();

      var resultsModel = new ResultsModel();
      resultsModel.GenerateResults();

      return importer.SendSummary();
    }