public ParticipationCreateViewModel() { if (!DesignTimeHelper.IsInDesignMode) { IConfiguration config = ConfigurationSource.Configuration; _participationDataStore = config.GetParticipationDataStore(); _shooterCollectionDataStore = config.GetShooterCollectionDataStore(); _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore(); _collectionShooterDataStore = config.GetCollectionShooterDataStore(); _shooterParticipationDataStore = config.GetShooterParticipationDataStore(); _shooterDataStore = config.GetShooterDataStore(); _personDataStore = config.GetPersonDataStore(); _windowService = config.GetWindowService(); _events = config.GetUIEvents(); _events.FetchSelectedParticipation += () => _selectedUiParticipation; LoadParticipations(); LoadAvailableShooters(); } OkCommand = new RelayCommand<ParticipationDraft>(ExecuteCreateParticipationCommand, CanExecuteCreateParticipationCommand); CancelCommand = new RelayCommand<object>(ExecuteCancelCommand); AssignCommand = new RelayCommand<UiShooter>(ExecuteAssignCommand, CanExecuteAssignCommand); RemoveCommand = new RelayCommand<UiShooter>(ExecuteRemoveCommand, CanExecuteRemoveCommand); DeleteCommand = new RelayCommand<UiShooterCollection>(ExecuteDeleteShooterCollectionCommand, CanExecuteDeleteShooterCollectionCommand); CreateCommand = new RelayCommand<UiParticipation>(ExecuteCreateShooterCollectionParticipation, CanExecuteShooterCollectionParticipation); }
public ShooterCreateViewModel() { AddToAssingedParticipationCommand = new RelayCommand <ParticipationListItem>(ExecuteAddToAssignedParticipationCommand, CanExecuteAddtoAssignedParticipationCommand); RemoveFromAssingedParticipationCommand = new RelayCommand <ShooterParticipationListItem>(ExecuteRemoveFromAssignedParticipationCommand, CanExecuteRemoveFromAssignedParticipationCommand); CancelCommand = new RelayCommand <object>(ExecuteCloseCommand); CreateShooterCommand = new RelayCommand <UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand); if (!DesignTimeHelper.IsInDesignMode) { IConfiguration config = ConfigurationSource.Configuration; _participationDataStore = config.GetParticipationDataStore(); _windowService = config.GetWindowService(); _shooterParticipationDataStore = config.GetShooterParticipationDataStore(); _uiEvents = config.GetUIEvents(); _uiEvents.PersonSelected += person => { UiPerson = person; }; _uiEvents.RequireSelectedPerson(); _shooterNumberService = config.GetShooterNumberService(); _shooterDataStore = config.GetShooterDataStore(); _shooterParticipationView = config.GetShooterParticipationView(); _ssvShooterDataWriterService = config.GetSsvShooterDataWriterService(); LoadAvailableParticipationList(); LoadAssignedParticipationList(); } }
private void RegisterRemoveParticipationFromShooterDialog(IShooterParticipationDataStore shooterParticipationDataStore) { _messenger.Register <RemoveParticipationFromShooterDialogMessage>(this, x => { YesNoMessageBoxViewModel vm = new YesNoMessageBoxViewModel { Caption = "Wettkampf löschen", DefaultYes = false, Message = string.Format("Wettkampfzuordnung '{0}' wirklich löschen?", x.Participation.ProgramName) }; IWindow w = _vs.ExecuteFunction <YesNoMessageBoxViewModel, IWindow>((IWindow)Current.MainWindow, vm); bool?result = w.ShowDialog(); if (!result.HasValue || !result.Value) { return; } ShooterParticipation shooterParticipation = shooterParticipationDataStore.FindByShooterId(x.ShooterId) .SingleOrDefault(sp => sp.ProgramNumber == x.Participation.ProgramNumber); shooterParticipationDataStore.Delete(shooterParticipation); _messenger.Send(new RefreshDataFromRepositoriesMessage()); }); }
public ShooterCreateViewModel() { AddToAssingedParticipationCommand = new RelayCommand<ParticipationListItem>(ExecuteAddToAssignedParticipationCommand, CanExecuteAddtoAssignedParticipationCommand); RemoveFromAssingedParticipationCommand = new RelayCommand<ShooterParticipationListItem>(ExecuteRemoveFromAssignedParticipationCommand, CanExecuteRemoveFromAssignedParticipationCommand); CancelCommand = new RelayCommand<object>(ExecuteCloseCommand); CreateShooterCommand = new RelayCommand<UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand); if (!DesignTimeHelper.IsInDesignMode) { IConfiguration config = ConfigurationSource.Configuration; _participationDataStore = config.GetParticipationDataStore(); _windowService = config.GetWindowService(); _shooterParticipationDataStore = config.GetShooterParticipationDataStore(); _uiEvents = config.GetUIEvents(); _uiEvents.PersonSelected += person => { UiPerson = person; }; _uiEvents.RequireSelectedPerson(); _shooterNumberService = config.GetShooterNumberService(); _shooterDataStore = config.GetShooterDataStore(); _shooterParticipationView = config.GetShooterParticipationView(); _ssvShooterDataWriterService = config.GetSsvShooterDataWriterService(); LoadAvailableParticipationList(); LoadAssignedParticipationList(); } }
public ParticipationCreateViewModel() { if (!DesignTimeHelper.IsInDesignMode) { IConfiguration config = ConfigurationSource.Configuration; _participationDataStore = config.GetParticipationDataStore(); _shooterCollectionDataStore = config.GetShooterCollectionDataStore(); _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore(); _collectionShooterDataStore = config.GetCollectionShooterDataStore(); _shooterParticipationDataStore = config.GetShooterParticipationDataStore(); _shooterDataStore = config.GetShooterDataStore(); _personDataStore = config.GetPersonDataStore(); _windowService = config.GetWindowService(); _events = config.GetUIEvents(); _events.FetchSelectedParticipation += () => _selectedUiParticipation; LoadParticipations(); LoadAvailableShooters(); } OkCommand = new RelayCommand <ParticipationDraft>(ExecuteCreateParticipationCommand, CanExecuteCreateParticipationCommand); CancelCommand = new RelayCommand <object>(ExecuteCancelCommand); AssignCommand = new RelayCommand <UiShooter>(ExecuteAssignCommand, CanExecuteAssignCommand); RemoveCommand = new RelayCommand <UiShooter>(ExecuteRemoveCommand, CanExecuteRemoveCommand); DeleteCommand = new RelayCommand <UiShooterCollection>(ExecuteDeleteShooterCollectionCommand, CanExecuteDeleteShooterCollectionCommand); CreateCommand = new RelayCommand <UiParticipation>(ExecuteCreateShooterCollectionParticipation, CanExecuteShooterCollectionParticipation); }
public ShooterEditViewModel() { AddToAssingedParticipationCommand = new RelayCommand <ParticipationListItem>(ExecuteAddToAssignedParticipationCommand, CanExecuteAddtoAssignedParticipationCommand); RemoveFromAssingedParticipationCommand = new RelayCommand <ShooterParticipationListItem>(ExecuteRemoveFromAssignedParticipationCommand, CanExecuteRemoveFromAssignedParticipationCommand); CancelCommand = new RelayCommand <object>(ExecuteCloseCommand); AssignShooterCollectionCommand = new RelayCommand <UiShooterCollection>(ExecuteAssignShooterCommand, CanExecuteAssignShooterCommand); if (!DesignTimeHelper.IsInDesignMode) { IConfiguration config = ConfigurationSource.Configuration; _participationDataStore = config.GetParticipationDataStore(); _windowService = config.GetWindowService(); _shooterParticipationDataStore = config.GetShooterParticipationDataStore(); _collectionShooterDataStore = config.GetCollectionShooterDataStore(); _personDataStore = config.GetPersonDataStore(); _uiEvents = config.GetUIEvents(); _uiEvents.ShooterSelected += shooter => { UiShooter = shooter; }; _uiEvents.RequireSelectedShooter(); _shooterNumberService = config.GetShooterNumberService(); _shooterDataStore = config.GetShooterDataStore(); _shooterParticipationView = config.GetShooterParticipationView(); _shooterCollectionDataStore = config.GetShooterCollectionDataStore(); _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore(); LoadData(); UiShooterCollections = new ObservableCollection <UiShooterCollection>(_shooterCollectionDataStore.GetAll().Select(UiBusinessObjectMapper.ToUiShooterCollection).OrderBy(_ => _.CollectionName)); } }
private void RegisterAddParticipationToShooterDialog(IShooterParticipationDataStore shooterParticipationDataStore) { _messenger.Register <AddParticipationToShooterDialogMessage>(this, x => { SelectParticipationViewModel vm = new SelectParticipationViewModel { Title = "Wettkampf auswählen" }; vm.Initialize(x.ShooterId); IWindow w = _vs.ExecuteFunction <SelectParticipationViewModel, IWindow>((IWindow)Current.MainWindow, vm); bool?result = w.ShowDialog(); if (!result.HasValue || !result.Value) { return; } ShooterParticipation sp = new ShooterParticipation { ProgramNumber = int.Parse(vm.SelectedParticipationDescription.ProgramNumber), ShooterId = x.ShooterId }; shooterParticipationDataStore.Create(sp); _messenger.Send(new RefreshDataFromRepositoriesMessage()); }); }
public void Initialize(Shooter shooter) { _shooterParticipationDataStore = ServiceLocator.Current.GetInstance <IShooterParticipationDataStore>(); _collectionShooterDataStore = ServiceLocator.Current.GetInstance <ICollectionShooterDataStore>(); _shooterCollectionDataStore = ServiceLocator.Current.GetInstance <IShooterCollectionDataStore>(); _sessionDataStore = ServiceLocator.Current.GetInstance <ISessionDataStore>(); _sessionSubtotalDataStore = ServiceLocator.Current.GetInstance <ISessionSubtotalDataStore>(); _shotDataStore = ServiceLocator.Current.GetInstance <IShotDataStore>(); _sdk = ServiceLocator.Current.GetInstance <ServiceDeskConfiguration>(); SelectedGrouping = null; SelectedParticipation = null; Shooter = shooter; Participations = new ObservableCollection <ParticipationViewModel>(FetchParticipationsByShooter(Shooter)); Groupings = new ObservableCollection <GroupingViewModel>(FetchGroupsByShooter(Shooter)); SelectedPersonChanged(shooter.ShooterId); MessengerInstance.Register <RefreshDataFromRepositoriesMessage>(this, x => { Groupings = new ObservableCollection <GroupingViewModel>(FetchGroupsByShooter(Shooter)); Participations = new ObservableCollection <ParticipationViewModel>(FetchParticipationsByShooter(Shooter)); SelectedPersonChanged(Shooter.ShooterId); }); }
public ShooterEditViewModel() { AddToAssingedParticipationCommand = new RelayCommand<ParticipationListItem>(ExecuteAddToAssignedParticipationCommand, CanExecuteAddtoAssignedParticipationCommand); RemoveFromAssingedParticipationCommand = new RelayCommand<ShooterParticipationListItem>(ExecuteRemoveFromAssignedParticipationCommand, CanExecuteRemoveFromAssignedParticipationCommand); CancelCommand = new RelayCommand<object>(ExecuteCloseCommand); AssignShooterCollectionCommand = new RelayCommand<UiShooterCollection>(ExecuteAssignShooterCommand, CanExecuteAssignShooterCommand); if (!DesignTimeHelper.IsInDesignMode) { IConfiguration config = ConfigurationSource.Configuration; _participationDataStore = config.GetParticipationDataStore(); _windowService = config.GetWindowService(); _shooterParticipationDataStore = config.GetShooterParticipationDataStore(); _collectionShooterDataStore = config.GetCollectionShooterDataStore(); _personDataStore = config.GetPersonDataStore(); _uiEvents = config.GetUIEvents(); _uiEvents.ShooterSelected += shooter => { UiShooter = shooter; }; _uiEvents.RequireSelectedShooter(); _shooterNumberService = config.GetShooterNumberService(); _shooterDataStore = config.GetShooterDataStore(); _shooterParticipationView = config.GetShooterParticipationView(); _shooterCollectionDataStore = config.GetShooterCollectionDataStore(); _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore(); LoadData(); UiShooterCollections = new ObservableCollection<UiShooterCollection>(_shooterCollectionDataStore.GetAll().Select(UiBusinessObjectMapper.ToUiShooterCollection).OrderBy(_ => _.CollectionName)); } }
public void Initialize(Shooter shooter) { _shooterParticipationDataStore = ServiceLocator.Current.GetInstance<IShooterParticipationDataStore>(); _collectionShooterDataStore = ServiceLocator.Current.GetInstance<ICollectionShooterDataStore>(); _shooterCollectionDataStore = ServiceLocator.Current.GetInstance<IShooterCollectionDataStore>(); _sessionDataStore = ServiceLocator.Current.GetInstance<ISessionDataStore>(); _sessionSubtotalDataStore = ServiceLocator.Current.GetInstance<ISessionSubtotalDataStore>(); _shotDataStore = ServiceLocator.Current.GetInstance<IShotDataStore>(); _sdk = ServiceLocator.Current.GetInstance<ServiceDeskConfiguration>(); SelectedGrouping = null; SelectedParticipation = null; Shooter = shooter; Participations = new ObservableCollection<ParticipationViewModel>(FetchParticipationsByShooter(Shooter)); Groupings = new ObservableCollection<GroupingViewModel>(FetchGroupsByShooter(Shooter)); SelectedPersonChanged(shooter.ShooterId); MessengerInstance.Register<RefreshDataFromRepositoriesMessage>(this, x => { Groupings = new ObservableCollection<GroupingViewModel>(FetchGroupsByShooter(Shooter)); Participations = new ObservableCollection<ParticipationViewModel>(FetchParticipationsByShooter(Shooter)); SelectedPersonChanged(Shooter.ShooterId); }); }
public MainViewModel() { if (DesignTimeHelper.IsInDesignMode) { _personDataStore = new FakePersonDataStore(); _shooterDataStore = new FakeShooterDataStore(); _participationDataStore = new FakeParticipationDataStore(); _groupMemberDetailsView = new FakeGroupMemberDetailsView(); _groupDetailsView = new FakeGroupDetailsView(); } else { IConfiguration config = ConfigurationSource.Configuration; _personDataStore = config.GetPersonDataStore(); _shooterDataStore = config.GetShooterDataStore(); _participationDataStore = config.GetParticipationDataStore(); _shooterParticipationDataStore = config.GetShooterParticipationDataStore(); _groupMemberDetailsView = config.GetGroupMemberDetailsView(); _shooterParticipationView = config.GetShooterParticipationView(); _groupDetailsView = config.GetGroupDetailsView(); _sessionDetailsView = config.GetSessionDetailsView(); _shooterDataWriterService = config.GetSsvShooterDataWriterService(); _collectionShooterDataStore = config.GetCollectionShooterDataStore(); _shooterCollectionDataStore = config.GetShooterCollectionDataStore(); _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore(); _shooterNumberService = config.GetShooterNumberService(); _windowService = config.GetWindowService(); _barcodePrintService = config.GetBarcodePrintService(); _barcodeBuilderService = config.GetBarcodeBuilderService(); _events = config.GetEvents(); _uiEvents = config.GetUIEvents(); _uiEvents.RequireSelectedPerson += () => _uiEvents.PersonSelected(SelectedUiPerson); _uiEvents.SelectPersonById += (id) => { SelectedUiPerson = UiPeople.FirstOrDefault(_ => _.PersonId == id); }; _uiEvents.RequireSelectedShooter += () => _uiEvents.ShooterSelected(SelectedUiShooter); _uiEvents.FetchSelectedShooter += () => SelectedUiShooter; _uiEvents.PersonDataStoreChanged += LoadPersonList; _uiEvents.ShooterDataStoreChanged += LoadShooterList; _shooterNumberService.Configure(_shooterDataStore); LoadPersonList(); LoadShooterList(); LoadParticipationList(); } CreatePersonCommand = new RelayCommand <object>(ExecuteCreatePersonCommand); EditPersonCommand = new RelayCommand <UiPerson>(ExecuteEditPersonCommand, CanExecuteEditPersonCommand); DeletePersonCommand = new RelayCommand <UiPerson>(ExecuteDeletePersonCommand, CanExecuteDeletePersonCommand); CreateShooterCommand = new RelayCommand <UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand); EditShooterCommand = new RelayCommand <UiShooter>(ExecuteEditShooterCommand, CanExecuteEditShooterCommand); DeleteShooterCommand = new RelayCommand <UiShooter>(ExecuteDeleteShooterCommand, CanExecuteDeleteShooterCommand); CreateParticipationCommand = new RelayCommand <object>(ExecuteCreateParticipationCommand); //EditParticipationCommand = new RelayCommand<UiParticipation> //DeleteParticipationCommand = new RelayCommand<UiParticipation> PrintBarcodeCommand = new RelayCommand <UiShooter>(ExecutePrintBarcodeCommand, CanExecutePrintBarcodeCommand); EditPassCommand = new RelayCommand <SessionDetails>(ExecuteEditPassCommand); }
public MainViewModel() { if (DesignTimeHelper.IsInDesignMode) { _personDataStore = new FakePersonDataStore(); _shooterDataStore = new FakeShooterDataStore(); _participationDataStore = new FakeParticipationDataStore(); _groupMemberDetailsView = new FakeGroupMemberDetailsView(); _groupDetailsView = new FakeGroupDetailsView(); } else { IConfiguration config = ConfigurationSource.Configuration; _personDataStore = config.GetPersonDataStore(); _shooterDataStore = config.GetShooterDataStore(); _participationDataStore = config.GetParticipationDataStore(); _shooterParticipationDataStore = config.GetShooterParticipationDataStore(); _groupMemberDetailsView = config.GetGroupMemberDetailsView(); _shooterParticipationView = config.GetShooterParticipationView(); _groupDetailsView = config.GetGroupDetailsView(); _sessionDetailsView = config.GetSessionDetailsView(); _shooterDataWriterService = config.GetSsvShooterDataWriterService(); _collectionShooterDataStore = config.GetCollectionShooterDataStore(); _shooterCollectionDataStore = config.GetShooterCollectionDataStore(); _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore(); _shooterNumberService = config.GetShooterNumberService(); _windowService = config.GetWindowService(); _barcodePrintService = config.GetBarcodePrintService(); _barcodeBuilderService = config.GetBarcodeBuilderService(); _events = config.GetEvents(); _uiEvents = config.GetUIEvents(); _uiEvents.RequireSelectedPerson += () => _uiEvents.PersonSelected(SelectedUiPerson); _uiEvents.SelectPersonById += (id) => { SelectedUiPerson = UiPeople.FirstOrDefault(_ => _.PersonId == id); }; _uiEvents.RequireSelectedShooter += () => _uiEvents.ShooterSelected(SelectedUiShooter); _uiEvents.FetchSelectedShooter += () => SelectedUiShooter; _uiEvents.PersonDataStoreChanged += LoadPersonList; _uiEvents.ShooterDataStoreChanged += LoadShooterList; _shooterNumberService.Configure(_shooterDataStore); LoadPersonList(); LoadShooterList(); LoadParticipationList(); } CreatePersonCommand = new RelayCommand<object>(ExecuteCreatePersonCommand); EditPersonCommand = new RelayCommand<UiPerson>(ExecuteEditPersonCommand, CanExecuteEditPersonCommand); DeletePersonCommand = new RelayCommand<UiPerson>(ExecuteDeletePersonCommand, CanExecuteDeletePersonCommand); CreateShooterCommand = new RelayCommand<UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand); EditShooterCommand = new RelayCommand<UiShooter>(ExecuteEditShooterCommand, CanExecuteEditShooterCommand); DeleteShooterCommand = new RelayCommand<UiShooter>(ExecuteDeleteShooterCommand, CanExecuteDeleteShooterCommand); CreateParticipationCommand = new RelayCommand<object>(ExecuteCreateParticipationCommand); //EditParticipationCommand = new RelayCommand<UiParticipation> //DeleteParticipationCommand = new RelayCommand<UiParticipation> PrintBarcodeCommand = new RelayCommand<UiShooter>(ExecutePrintBarcodeCommand, CanExecutePrintBarcodeCommand); EditPassCommand = new RelayCommand<SessionDetails>(ExecuteEditPassCommand); }
public void Initialize() { _personDataStore = ServiceLocator.Current.GetInstance <IPersonDataStore>(); _shooterDataStore = ServiceLocator.Current.GetInstance <IShooterDataStore>(); _sessionDataStore = ServiceLocator.Current.GetInstance <ISessionDataStore>(); _sessionSubtotalDataStore = ServiceLocator.Current.GetInstance <ISessionSubtotalDataStore>(); _shotDataStore = ServiceLocator.Current.GetInstance <IShotDataStore>(); _shooterParticipationDataStore = ServiceLocator.Current.GetInstance <IShooterParticipationDataStore>(); _sdk = ServiceLocator.Current.GetInstance <ServiceDeskConfiguration>(); }
public void Initialize() { _personDataStore = ServiceLocator.Current.GetInstance<IPersonDataStore>(); _shooterDataStore = ServiceLocator.Current.GetInstance<IShooterDataStore>(); _sessionDataStore = ServiceLocator.Current.GetInstance<ISessionDataStore>(); _sessionSubtotalDataStore = ServiceLocator.Current.GetInstance<ISessionSubtotalDataStore>(); _shotDataStore = ServiceLocator.Current.GetInstance<IShotDataStore>(); _shooterParticipationDataStore = ServiceLocator.Current.GetInstance<IShooterParticipationDataStore>(); _sdk = ServiceLocator.Current.GetInstance<ServiceDeskConfiguration>(); }
public void Initialize(int shooterId) { ServiceDeskConfiguration serviceDeskConfiguration = ServiceLocator.Current.GetInstance <ServiceDeskConfiguration>(); IShooterDataStore shooterDataStore = ServiceLocator.Current.GetInstance <IShooterDataStore>(); IPersonDataStore personDataStore = ServiceLocator.Current.GetInstance <IPersonDataStore>(); ICollectionShooterDataStore collectionShooterDataStore = ServiceLocator.Current.GetInstance <ICollectionShooterDataStore>(); IShooterCollectionDataStore shooterCollectionDataStore = ServiceLocator.Current.GetInstance <IShooterCollectionDataStore>(); IShooterParticipationDataStore shooterParticipationDataStore = ServiceLocator.Current.GetInstance <IShooterParticipationDataStore>(); // Get PrgramNumbers in which the shooter is enroled. List <int> programNumbers = (from sp in shooterParticipationDataStore.FindByShooterId(shooterId) select sp.ProgramNumber).ToList(); // Get all CollectionShooters grouped by their ShooterCollections Participation ProgramNumber IEnumerable <IGrouping <int, CollectionShooter> > collectionShootersGroupedByProgramNumber = from p in programNumbers join sc in shooterCollectionDataStore.GetAll() on p equals sc.ProgramNumber join cs in collectionShooterDataStore.GetAll() on sc.ShooterCollectionId equals cs.ShooterCollectionId group cs by p; // Program Numbers with which the current shooter is not yet enroled as a CollectionShooter IEnumerable <int> programNumbersAlreadyEnroled = from scg in collectionShootersGroupedByProgramNumber where scg.Any(x => x.ShooterId == shooterId) select scg.Key; // Final list of ShooterCollections which are relevant for the current shooter IEnumerable <ShooterCollection> shooterCollectionsFinal = from p in programNumbers join sc in shooterCollectionDataStore.GetAll() on p equals sc.ProgramNumber where !programNumbersAlreadyEnroled.Contains(p) select sc; IEnumerable <GroupingViewModel> groupingViewModels = from sc in shooterCollectionsFinal join p in serviceDeskConfiguration.ParticipationDescriptions.GetAll() on sc.ProgramNumber.ToString() equals p.ProgramNumber select new GroupingViewModel { ShooterCollectionId = sc.ShooterCollectionId, GroupingName = sc.CollectionName, ParticipationName = p.ProgramName, Shooters = new ObservableCollection <PersonShooterViewModel>(from cs in collectionShooterDataStore.GetAll() join s in shooterDataStore.GetAll() on cs.ShooterId equals s.ShooterId join person in personDataStore.GetAll() on s.PersonId equals person.PersonId where cs.ShooterCollectionId == sc.ShooterCollectionId select new PersonShooterViewModel(person, s)) }; Groupings = new ObservableCollection <GroupingViewModel>(groupingViewModels); }
public void Initialize(int shooterId) { ServiceDeskConfiguration sdk = ServiceLocator.Current.GetInstance <ServiceDeskConfiguration>(); IShooterParticipationDataStore shooterParticipationDataStore = ServiceLocator.Current.GetInstance <IShooterParticipationDataStore>(); var programNumberToShooterParticipations = from sp in shooterParticipationDataStore.GetAll() join p in sdk.ParticipationDescriptions.GetAll() on sp.ProgramNumber.ToString() equals p.ProgramNumber where sp.ShooterId == shooterId group sp by p.ProgramNumber into gj select new { ProgramNumber = gj.Key, ShooterParticipations = gj.Select(x => x) }; var selectableParticipations = from p in sdk.ParticipationDescriptions.GetAll() where (!programNumberToShooterParticipations.Any(x => x.ProgramNumber == p.ProgramNumber) || !programNumberToShooterParticipations.Single(x => x.ProgramNumber == p.ProgramNumber) .ShooterParticipations.Any()) select p; ParticipationDescriptions = new ObservableCollection <ParticipationDescription>(selectableParticipations); }
public void Initialize(int programNumber) { IPersonDataStore personDataStore = ServiceLocator.Current.GetInstance <IPersonDataStore>(); IShooterDataStore shooterDataStore = ServiceLocator.Current.GetInstance <IShooterDataStore>(); ICollectionShooterDataStore collectionShooterDataStore = ServiceLocator.Current.GetInstance <ICollectionShooterDataStore>(); IShooterCollectionDataStore shooterCollectionDataStore = ServiceLocator.Current.GetInstance <IShooterCollectionDataStore>(); IShooterParticipationDataStore shooterParticipationDataStore = ServiceLocator.Current.GetInstance <IShooterParticipationDataStore>(); // ShooterIds enroled in ProgramNumber IEnumerable <int> shooters = from sp in shooterParticipationDataStore.FindByProgramNumber(programNumber) select sp.ShooterId; // ShooterIds with a ShooterCollection participating in ProgramNumber IEnumerable <int> shootersWithCollectionInProgramNumber = from cs in collectionShooterDataStore.GetAll() join sc in shooterCollectionDataStore.GetAll() on cs.ShooterCollectionId equals sc.ShooterCollectionId where sc.ProgramNumber == programNumber select cs.ShooterId; IEnumerable <int> shootersFinal = shooters.Except(shootersWithCollectionInProgramNumber); IEnumerable <PersonShooterViewModel> result = from shooterId in shootersFinal join s in shooterDataStore.GetAll() on shooterId equals s.ShooterId join p in personDataStore.GetAll() on s.PersonId equals p.PersonId select new PersonShooterViewModel { PersonId = p.PersonId, FirstName = p.FirstName, LastName = p.LastName, DateOfBirth = p.DateOfBirth, ShooterId = s.ShooterId, ShooterNumber = s.ShooterNumber }; Shooters = new ObservableCollection <PersonShooterViewModel>(result); }
private IEnumerable <Tuple <Person, int, decimal, decimal> > GetBestResults(int programNumber) { IShooterDataStore shooterDataStore = ServiceLocator.Current.GetInstance <IShooterDataStore>(); IShooterParticipationDataStore shooterParticipationDataStore = ServiceLocator.Current.GetInstance <IShooterParticipationDataStore>(); ISessionDataStore sessionDataStore = ServiceLocator.Current.GetInstance <ISessionDataStore>(); ISessionSubtotalDataStore sessionSubtotalDataStore = ServiceLocator.Current.GetInstance <ISessionSubtotalDataStore>(); IShotDataStore shotDataStore = ServiceLocator.Current.GetInstance <IShotDataStore>(); IPersonDataStore personDataStore = ServiceLocator.Current.GetInstance <IPersonDataStore>(); List <Shooter> shooters = (from s in shooterDataStore.GetAll() join sp in shooterParticipationDataStore.GetAll() on s.ShooterId equals sp.ShooterId where sp.ProgramNumber == programNumber select s).ToList(); // Person, ShooterId, TotalScore, DeepShot List <Tuple <Person, int, decimal, decimal> > result = new List <Tuple <Person, int, decimal, decimal> >(); foreach (Shooter shooter in shooters) { // Get the relevant sessions var lShooter = shooter; IEnumerable <Session> sessions = from s in sessionDataStore.GetAll() where s.ShooterId == lShooter.ShooterId && s.ProgramNumber == programNumber select s; // Get the results to the sessions var maxScoreGrouping = from session in sessions join subTotal in sessionSubtotalDataStore.GetAll() on session.SessionId equals subTotal.SessionId join shot in shotDataStore.GetAll() on subTotal.SessionSubtotalId equals shot.SubtotalId group shot by session into grouping select new { Session = grouping.Key, TotalScore = grouping.Sum(x => x.PrimaryScore) }; // Get the max scores of each session var bestGrouping = maxScoreGrouping.OrderByDescending(x => x.TotalScore).FirstOrDefault(); if (bestGrouping != null) { // select the max score as the result which shall go into ranking decimal maxScore = bestGrouping.TotalScore; decimal?deepShot = (from subTotal in sessionSubtotalDataStore.GetAll() join shot in shotDataStore.GetAll() on subTotal.SessionSubtotalId equals shot.SubtotalId where subTotal.SessionId == bestGrouping.Session.SessionId orderby shot.SecondaryScore descending select shot.SecondaryScore).FirstOrDefault(); if (lShooter.PersonId.HasValue) { Person person = personDataStore.FindById(lShooter.PersonId.Value); result.Add(new Tuple <Person, int, decimal, decimal>(person, shooter.ShooterId, maxScore, deepShot ?? 0)); } } } return(result); }
private void RegisterRemoveParticipationFromShooterDialog(IShooterParticipationDataStore shooterParticipationDataStore) { _messenger.Register<RemoveParticipationFromShooterDialogMessage>(this, x => { YesNoMessageBoxViewModel vm = new YesNoMessageBoxViewModel { Caption = "Wettkampf löschen", DefaultYes = false, Message = string.Format("Wettkampfzuordnung '{0}' wirklich löschen?", x.Participation.ProgramName) }; IWindow w = _vs.ExecuteFunction<YesNoMessageBoxViewModel, IWindow>((IWindow) Current.MainWindow, vm); bool? result = w.ShowDialog(); if (!result.HasValue || !result.Value) return; ShooterParticipation shooterParticipation = shooterParticipationDataStore.FindByShooterId(x.ShooterId) .SingleOrDefault(sp => sp.ProgramNumber == x.Participation.ProgramNumber); shooterParticipationDataStore.Delete(shooterParticipation); _messenger.Send(new RefreshDataFromRepositoriesMessage()); }); }
private void RegisterAddParticipationToShooterDialog(IShooterParticipationDataStore shooterParticipationDataStore) { _messenger.Register<AddParticipationToShooterDialogMessage>(this, x => { SelectParticipationViewModel vm = new SelectParticipationViewModel { Title = "Wettkampf auswählen" }; vm.Initialize(x.ShooterId); IWindow w = _vs.ExecuteFunction<SelectParticipationViewModel, IWindow>((IWindow) Current.MainWindow, vm); bool? result = w.ShowDialog(); if (!result.HasValue || !result.Value) return; ShooterParticipation sp = new ShooterParticipation { ProgramNumber = int.Parse(vm.SelectedParticipationDescription.ProgramNumber), ShooterId = x.ShooterId }; shooterParticipationDataStore.Create(sp); _messenger.Send(new RefreshDataFromRepositoriesMessage()); }); }