private void RegisterReassignShooterNumberDialog(ISessionDataStore sessionDataStore) { _messenger.Register <ShowReassignShooterNumberDialogMessage>(this, x => { ReassignProgramNumberViewModel vm = new ReassignProgramNumberViewModel { Title = "Programm neu zuweisen" }; vm.Initialize(x.SessionId); IWindow w = _vs.ExecuteFunction <ReassignProgramNumberViewModel, IWindow>((IWindow)Current.MainWindow, vm); bool?result = w.ShowDialog(); if (!result.HasValue || !result.Value) { return; } Session s = sessionDataStore.FindById(x.SessionId); s.ProgramNumber = vm.SelectedParticipation.ProgramNumber; sessionDataStore.Update(s); _messenger.Send(new RefreshDataFromRepositoriesMessage()); }); }
private void SelectedPersonChanged() { if (MessengerInstance == null) { return; } if (SelectedPerson != null) { Dictionary <int, List <int> > sessionToSubsession = (from session in _sessionDataStore.FindByShooterId(SelectedPerson.ShooterId) join subsession in _sessionSubtotalDataStore.GetAll() on session.SessionId equals subsession.SessionId orderby session.ProgramNumber group subsession by session.SessionId).ToDictionary(_ => _.Key, _ => _.Select(fo => fo.SessionSubtotalId).ToList()); Sessions = new ObservableCollection <SessionViewModel>(); foreach (KeyValuePair <int, List <int> > keyValuePair in sessionToSubsession) { Session session = _sessionDataStore.FindById(keyValuePair.Key); { ParticipationDescription participation = _sdk.ParticipationDescriptions.GetAll() .SingleOrDefault(x => x.ProgramNumber == session.ProgramNumber.ToString()); string programName = participation == null ? "unknown" : participation.ProgramName; SessionViewModel svm = new SessionViewModel { LaneNumber = session.LaneNumber, ProgramName = string.Format("{0} [{1}]", programName, session.ProgramNumber), SessionId = session.SessionId, ShooterIsParticipating = _shooterParticipationDataStore.FindByShooterId(SelectedPerson.ShooterId).Any(x => x.ProgramNumber == session.ProgramNumber) }; List <Shot> shots = new List <Shot>(); foreach (int subsessionId in keyValuePair.Value) { shots.AddRange(_shotDataStore.FindBySubSessionId(subsessionId).OrderBy(shot => shot.Ordinal)); } svm.Shots = new ObservableCollection <Shot>(shots); svm.Total = shots.Sum(s => s.PrimaryScore); Sessions.Add(svm); } } } else { Sessions = new ObservableCollection <SessionViewModel>(); } }
private void RegisterReassignShooterNumberDialog(ISessionDataStore sessionDataStore) { _messenger.Register<ShowReassignShooterNumberDialogMessage>(this, x => { ReassignProgramNumberViewModel vm = new ReassignProgramNumberViewModel { Title = "Programm neu zuweisen" }; vm.Initialize(x.SessionId); IWindow w = _vs.ExecuteFunction<ReassignProgramNumberViewModel, IWindow>((IWindow)Current.MainWindow, vm); bool? result = w.ShowDialog(); if (!result.HasValue || !result.Value) return; Session s = sessionDataStore.FindById(x.SessionId); s.ProgramNumber = vm.SelectedParticipation.ProgramNumber; sessionDataStore.Update(s); _messenger.Send(new RefreshDataFromRepositoriesMessage()); }); }