private void RegisterResults(int uptoTeamNumber) { if (this.Leon == null || this.OrionResultViewModel == null || this.MainOrionViewModel == null) { return; } var toBeRegistered = Leon.LeonPersons.Where(l => l.Team <= uptoTeamNumber).Select(l => l.ShooterId).ToList(); if (toBeRegistered != null && toBeRegistered.Any()) { if (m_minneViewModel != null && m_minneViewModel.MinneRegistrations != null) { LeonWriter.WriteLeonResults( toBeRegistered, this.OrionResultViewModel.OrionResults, this.MainOrionViewModel, this.Leon.LeonPersons, this.m_minneViewModel.MinneRegistrations); } else { LeonWriter.WriteLeonResults( toBeRegistered, this.OrionResultViewModel.OrionResults, this.MainOrionViewModel, this.Leon.LeonPersons, null); } } }
void OrionResultViewModel_NewOrionResults(object sender, Orion.OrionResultsEventArgs e) { var newResults = e.NewResults; List <int> finishedShooters; var updatedRegistrations = m_orionResultUpdater.GetUpdatedRegistrationsAfterResultRegistration( newResults, this.OrionTeamsSetupViewModel.OrionRegistrations, this.OrionResultViewModel.OrionResults, out finishedShooters); if (finishedShooters.Any()) { var finishedPersons = Leon.LeonPersons.Where(l => finishedShooters.Contains(l.ShooterId)); var maxTeamNumber = finishedPersons.Max(f => f.Team); var shouldBeFinished = Leon.LeonPersons.Where(l => l.Team <= maxTeamNumber).Select(l => l.ShooterId); var finishedRegistrations = DatabaseApi.LoadCompetitionFromTable(TableName.FinishedShooter).OfType <FinishedPerson>().Select(f => f.ShooterId); var missingPersons = shouldBeFinished.Except(finishedRegistrations).Except(finishedShooters); finishedShooters.AddRange(missingPersons); } this.OrionCommunicationViewModel.UpdateChangesToOrion(updatedRegistrations); this.OrionResultViewModel.AddNewRegistrations(newResults); if (finishedShooters != null && finishedShooters.Any()) { if (m_minneViewModel != null && m_minneViewModel.MinneRegistrations != null) { LeonWriter.WriteLeonResults( finishedShooters, this.OrionResultViewModel.OrionResults, this.MainOrionViewModel, this.Leon.LeonPersons, this.m_minneViewModel.MinneRegistrations); } else { LeonWriter.WriteLeonResults( finishedShooters, this.OrionResultViewModel.OrionResults, this.MainOrionViewModel, this.Leon.LeonPersons, null); } } }