Beispiel #1
0
        private void RegisterDeletePersonDialog(IPersonDataStore personDataStore)
        {
            _messenger.Register <DeletePersonDialogMessage>(this,
                                                            x =>
            {
                YesNoMessageBoxViewModel vm = new YesNoMessageBoxViewModel
                {
                    DefaultYes = false,
                    Caption    = "Person löschen?",
                    Message    =
                        string.Format("Möchtest du die Person '{0} {1}' wirklich löschen?",
                                      x.FirstName,
                                      x.LastName)
                };

                IWindow w   = _vs.ExecuteFunction <YesNoMessageBoxViewModel, IWindow>((IWindow)Current.MainWindow, vm);
                bool?result = w.ShowDialog();
                if (!result.HasValue || !result.Value)
                {
                    return;
                }

                Person person = personDataStore.FindById(x.PersonId);
                personDataStore.Delete(person);
                _messenger.Send(new RefreshDataFromRepositoriesMessage());
            });
        }
Beispiel #2
0
        private void RegisterCreatePersonDialog(IPersonDataStore personDataStore)
        {
            _messenger.Register <CreatePersonDialogMessage>(this,
                                                            x =>
            {
                var m = new CreatePersonViewModel
                {
                    Title = "Person erstellen"
                };
                IWindow w   = _vs.ExecuteFunction <CreatePersonViewModel, IWindow>((IWindow)Current.MainWindow, m);
                bool?result = w.ShowDialog();
                if (!result.HasValue || !result.Value)
                {
                    return;
                }

                Person person = new Person
                {
                    FirstName   = m.FirstName,
                    LastName    = m.LastName,
                    DateOfBirth = m.DateOfBirth,
                    Address     = m.Address,
                    City        = m.City,
                    ZipCode     = m.ZipCode,
                    Email       = m.Email,
                    Phone       = m.Phone
                };
                personDataStore.Create(person);
                _messenger.Send(new RefreshDataFromRepositoriesMessage());
                _messenger.Send(new SetSelectedPersonMessage(person.PersonId));
            });
        }
        public static UiParticipation FetchShooters(this UiParticipation participation,
                                                    IShooterCollectionParticipationDataStore shooterCollectionParticipationDataStore,
                                                    IShooterCollectionDataStore shooterCollectionDataStore,
                                                    ICollectionShooterDataStore collectionShooterDataStore,
                                                    IShooterDataStore shooterDataStore,
                                                    IPersonDataStore personDataStore)
        {
            participation.ShooterCollections = new List <UiShooterCollection>();
            List <ShooterCollectionParticipation> shooterCollectionParticipations =
                shooterCollectionParticipationDataStore.FindByIdParticipationId(participation.ParticipationId).ToList();
            List <ShooterCollection> shooterCollections = shooterCollectionParticipations.Select(_ => shooterCollectionDataStore.FindById(_.ShooterCollectionId)).ToList();

            foreach (ShooterCollection shooterCollection in shooterCollections)
            {
                List <CollectionShooter> collectionShooters =
                    collectionShooterDataStore.FindByShooterCollectionId(shooterCollection.ShooterCollectionId).ToList();

                participation.ShooterCollections.Add(new UiShooterCollection
                {
                    CollectionName      = shooterCollection.CollectionName,
                    ShooterCollectionId = shooterCollection.ShooterCollectionId,
                    Shooters            = collectionShooters.Select(_ => ToUiShooter(shooterDataStore.FindById(_.ShooterId)).FetchPerson(personDataStore))
                });
            }

            return(participation);
        }
    public EditPassViewModel()
    {
      if (!DesignTimeHelper.IsInDesignMode)
      {
        IConfiguration config = ConfigurationSource.Configuration;
        _shooterDatastore = config.GetShooterDataStore();
        _sessionDatastore = config.GetSessionDataStore();
        _programItemDatastore = config.GetProgramItemDataStore();
        _personDatastore = config.GetPersonDataStore();
        _windowService = config.GetWindowService();
        _events = config.GetUIEvents();

        List<UiShooter> shooters = _shooterDatastore.GetAll().Select(UiBusinessObjectMapper.ToUiShooter).ToList();
        shooters.ForEach(_ => { if (_.PersonId != null) _.FetchPerson(_personDatastore.FindById((int) _.PersonId)); });
        UiShooters = new ObservableCollection<UiShooter>(shooters.OrderBy(_ => _.LastName).ThenBy(_ => _.FirstName));

        SearchShooterCommand = new RelayCommand<string>(ExecuteSearchShooterCommand, CanExecuteSearchShooterCommand);
        DeleteCommand = new RelayCommand<UiSession>(ExecuteDeleteCommand, CanExecuteDeleteCommand);
        CancelCommand = new RelayCommand<object>(ExecuteCancelCommand);
        SaveCommand = new RelayCommand<UiShooter>(ExecuteSaveCommand, CanExecuteSaveCommand);
        UiShooter selectedUiShooter = _events.FetchSelectedShooter();

        if (selectedUiShooter != null)
        {
          ShooterNumber = string.Format("{0}", selectedUiShooter.ShooterNumber);
          ExecuteSearchShooterCommand(ShooterNumber);
        }
      }
    }
    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 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));
            }
        }
Beispiel #7
0
        public DefaultConfiguration()
        {
            //_shootingRange = new SiusDataFileProvider(@"C:\Users\eberlid\Dropbox\SSC\2014\Herbstschiessen\ShootingRange\20140516_164043.log");
            //_shootingRange = new SiusDataFileProvider(@"C:\Users\eberlid\Documents\My Dropbox\SSC\2014\Herbstschiessen\ShootingRange\20140516_164043.log");
            //_shootingRange = new SiusDataFileProvider(@"C:\Users\eberlid\Dropbox\SSC\2014\Herbstschiessen\ShootingRange\20130914_132912.log");
            //_shootingRange = new SiusApiProvider("http://192.168.1.4");
            _shootingRange = new SiusDataSocketProvider("127.0.0.1", 4000);
            _events        = new ShootingRangeEvents();
            _uiEvents      = new UIEvents();
            ShootingRangeEntities entities = new ShootingRangeEntities();

            _personRepository                        = new PersonDataStore(entities);
            _shooterRepository                       = new ShooterDataStore(entities);
            _participationDataStore                  = new ParticipationDataStore(entities);
            _sessionDataStore                        = new SessionDataStore(entities);
            _shotDataStore                           = new ShotDataStore(entities);
            _sessionDetailsView                      = new SessionDetailsView(entities);
            _shooterNumberConfigDataStore            = new ShooterNumberConfigDataStore(entities);
            _shooterParticipationDataStore           = new ShooterParticipationDataStore(entities);
            _sessionSubtotalDataStore                = new SessionSubtotalDataStore(entities);
            _programItemDataStore                    = new ProgramItemDataStore(entities);
            _groupMemberDetailsView                  = new GroupMemberDetailsView(entities);
            _groupDetailsView                        = new GroupDetailsView(entities);
            _shooterParticipationView                = new ShooterParticipationView(entities);
            _windowService                           = new WindowService();
            _barcodePrintService                     = new PtouchBarcodePrinter();
            _barcodeBuilderService                   = new Barcode2Of5InterleavedService();
            _shooterNumberService                    = new ShooterNumberService(_shooterNumberConfigDataStore);
            _shooterCollectionParticipationDataStore = new ShooterCollectionParticipationDataStore(entities);
            _shooterCollectionDataStore              = new ShooterCollectionDataStore(entities);
            _collectionShooterDataStore              = new CollectionShooterDataStore(entities);
            _ssvShooterDataWriterService             = new SsvFileWriter(@"C:\Sius\SiusData\SSVDaten\SSV_schuetzen.txt");
        }
Beispiel #8
0
        public EditPassViewModel()
        {
            if (!DesignTimeHelper.IsInDesignMode)
            {
                IConfiguration config = ConfigurationSource.Configuration;
                _shooterDatastore     = config.GetShooterDataStore();
                _sessionDatastore     = config.GetSessionDataStore();
                _programItemDatastore = config.GetProgramItemDataStore();
                _personDatastore      = config.GetPersonDataStore();
                _windowService        = config.GetWindowService();
                _events = config.GetUIEvents();

                List <UiShooter> shooters = _shooterDatastore.GetAll().Select(UiBusinessObjectMapper.ToUiShooter).ToList();
                shooters.ForEach(_ => { if (_.PersonId != null)
                                        {
                                            _.FetchPerson(_personDatastore.FindById((int)_.PersonId));
                                        }
                                 });
                UiShooters = new ObservableCollection <UiShooter>(shooters.OrderBy(_ => _.LastName).ThenBy(_ => _.FirstName));

                SearchShooterCommand = new RelayCommand <string>(ExecuteSearchShooterCommand, CanExecuteSearchShooterCommand);
                DeleteCommand        = new RelayCommand <UiSession>(ExecuteDeleteCommand, CanExecuteDeleteCommand);
                CancelCommand        = new RelayCommand <object>(ExecuteCancelCommand);
                SaveCommand          = new RelayCommand <UiShooter>(ExecuteSaveCommand, CanExecuteSaveCommand);
                UiShooter selectedUiShooter = _events.FetchSelectedShooter();

                if (selectedUiShooter != null)
                {
                    ShooterNumber = string.Format("{0}", selectedUiShooter.ShooterNumber);
                    ExecuteSearchShooterCommand(ShooterNumber);
                }
            }
        }
 public DefaultConfiguration()
 {
   //_shootingRange = new SiusDataFileProvider(@"C:\Users\eberlid\Dropbox\SSC\2014\Herbstschiessen\ShootingRange\20140516_164043.log");
   //_shootingRange = new SiusDataFileProvider(@"C:\Users\eberlid\Documents\My Dropbox\SSC\2014\Herbstschiessen\ShootingRange\20140516_164043.log");
   //_shootingRange = new SiusDataFileProvider(@"C:\Users\eberlid\Dropbox\SSC\2014\Herbstschiessen\ShootingRange\20130914_132912.log");
   //_shootingRange = new SiusApiProvider("http://192.168.1.4");
   _shootingRange = new SiusDataSocketProvider("127.0.0.1", 4000);
   _events = new ShootingRangeEvents();
   _uiEvents = new UIEvents();
   ShootingRangeEntities entities = new ShootingRangeEntities();
   _personRepository = new PersonDataStore(entities);
   _shooterRepository = new ShooterDataStore(entities);
   _participationDataStore = new ParticipationDataStore(entities);
   _sessionDataStore = new SessionDataStore(entities);
   _shotDataStore = new ShotDataStore(entities);
   _sessionDetailsView = new SessionDetailsView(entities);
   _shooterNumberConfigDataStore = new ShooterNumberConfigDataStore(entities);
   _shooterParticipationDataStore = new ShooterParticipationDataStore(entities);
   _sessionSubtotalDataStore = new SessionSubtotalDataStore(entities);
   _programItemDataStore = new ProgramItemDataStore(entities);
   _groupMemberDetailsView = new GroupMemberDetailsView(entities);
   _groupDetailsView = new GroupDetailsView(entities);
   _shooterParticipationView = new ShooterParticipationView(entities);
   _windowService = new WindowService();
   _barcodePrintService = new PtouchBarcodePrinter();
   _barcodeBuilderService = new Barcode2Of5InterleavedService();
   _shooterNumberService = new ShooterNumberService(_shooterNumberConfigDataStore);
   _shooterCollectionParticipationDataStore = new ShooterCollectionParticipationDataStore(entities);
   _shooterCollectionDataStore = new ShooterCollectionDataStore(entities);
   _collectionShooterDataStore = new CollectionShooterDataStore(entities);
   _ssvShooterDataWriterService = new SsvFileWriter(@"C:\Sius\SiusData\SSVDaten\SSV_schuetzen.txt");
 }
        private void LoadShooterCollections(int programNumber)
        {
            IShooterCollectionDataStore shooterCollectionDataStore = ServiceLocator.Current.GetInstance <IShooterCollectionDataStore>();
            ICollectionShooterDataStore collectionShooterDataStore = ServiceLocator.Current.GetInstance <ICollectionShooterDataStore>();
            IShooterDataStore           shooterDataStore           = ServiceLocator.Current.GetInstance <IShooterDataStore>();
            IPersonDataStore            personDataStore            = ServiceLocator.Current.GetInstance <IPersonDataStore>();

            IEnumerable <ShooterCollectionViewModel> scvm = from sc in shooterCollectionDataStore.GetAll()
                                                            where sc.ProgramNumber == programNumber
                                                            select new ShooterCollectionViewModel
            {
                CollectionName      = sc.CollectionName,
                ShooterCollectionId = sc.ShooterCollectionId,
                Shooters            =
                    new ObservableCollection <UiCollectionShooter>(from cs in collectionShooterDataStore.GetAll()
                                                                   where cs.ShooterCollectionId == sc.ShooterCollectionId
                                                                   join s in shooterDataStore.GetAll() on cs.ShooterId equals s.ShooterId
                                                                   join p in personDataStore.GetAll() on s.PersonId equals p.PersonId
                                                                   orderby p.FirstName
                                                                   orderby p.LastName
                                                                   select new UiCollectionShooter
                {
                    ShooterId     = s.ShooterId,
                    PersonId      = p.PersonId,
                    FirstName     = p.FirstName,
                    LastName      = p.LastName,
                    ShooterNumber = s.ShooterNumber
                })
            };

            ShooterCollections = new ObservableCollection <ShooterCollectionViewModel>(scvm.OrderBy(_ => _.CollectionName));
        }
Beispiel #11
0
        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 static UiShooter FetchPerson(this UiShooter shooter, IPersonDataStore personDataStore)
    {
      if (shooter.PersonId != null)
      {
        shooter.FetchPerson(personDataStore.FindById((int) shooter.PersonId));
      }

      return shooter;
    }
        public static UiShooter FetchPerson(this UiShooter shooter, IPersonDataStore personDataStore)
        {
            if (shooter.PersonId != null)
            {
                shooter.FetchPerson(personDataStore.FindById((int)shooter.PersonId));
            }

            return(shooter);
        }
Beispiel #15
0
 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 sessionId)
        {
            IPersonDataStore  personDataStore  = ServiceLocator.Current.GetInstance <IPersonDataStore>();
            IShooterDataStore shooterDataStore = ServiceLocator.Current.GetInstance <IShooterDataStore>();

            Shooters = new ObservableCollection <PersonShooterViewModel>(
                from p in personDataStore.GetAll()
                join s in shooterDataStore.GetAll() on p.PersonId equals s.PersonId orderby p.FirstName orderby p.LastName
                select new PersonShooterViewModel(p, s)
                );
        }
        public ShootingRangeEngine(IContainer container)
        {
            _sessionsAwaitingProgramNumber = new Dictionary <int, Session>();
            _sessionsOngoing = new Dictionary <int, Session>();

            _shootingRange      = container.Resolve <IShootingRange>();
            _shootingRange.Log += ShootingRangeOnLog;

            _sessionDataStore         = container.Resolve <ISessionDataStore>();
            _sessionSubtotalDataStore = container.Resolve <ISessionSubtotalDataStore>();
            _shotDataStore            = container.Resolve <IShotDataStore>();
            _shooterDataStore         = container.Resolve <IShooterDataStore>();
            _personDataStore          = container.Resolve <IPersonDataStore>();
        }
        public ShootingRangeEngine(IContainer container)
        {
            _sessionsAwaitingProgramNumber = new Dictionary<int, Session>();
            _sessionsOngoing = new Dictionary<int, Session>();

            _shootingRange = container.Resolve<IShootingRange>();
            _shootingRange.Log += ShootingRangeOnLog;

            _sessionDataStore = container.Resolve<ISessionDataStore>();
            _sessionSubtotalDataStore = container.Resolve<ISessionSubtotalDataStore>();
            _shotDataStore = container.Resolve<IShotDataStore>();
            _shooterDataStore = container.Resolve<IShooterDataStore>();
            _personDataStore = container.Resolve<IPersonDataStore>();
        }
        public void Initialize()
        {
            _personDataStore            = ServiceLocator.Current.GetInstance <IPersonDataStore>();
            _shooterDataStore           = ServiceLocator.Current.GetInstance <IShooterDataStore>();
            _shooterNumberService       = ServiceLocator.Current.GetInstance <IShooterNumberService>();
            _shooterDataWriter          = ServiceLocator.Current.GetInstance <ISsvShooterDataWriterService>();
            _collectionShooterDataStore = ServiceLocator.Current.GetInstance <ICollectionShooterDataStore>();
            _shooterCollectionDataStore = ServiceLocator.Current.GetInstance <IShooterCollectionDataStore>();
            _serviceDeskConfiguration   = ServiceLocator.Current.GetInstance <ServiceDeskConfiguration>();

            MessengerInstance.Register <PersonSelectedMessage>(this,
                                                               x =>
            {
                UpdateCommandCanExecuteOnSelectedPersonChanged();
                LoadShooters(x.PersonId);
            });
            MessengerInstance.Register <SetSelectedPersonMessage>(this,
                                                                  x =>
            {
                SelectedPerson = FilteredPersons.FirstOrDefault(person => person.PersonId == x.PersonId);
            });
            MessengerInstance.Register <SetSelectedShooterMessage>(this,
                                                                   x =>
            {
                SelectedShooter = Shooters.FirstOrDefault(s => s.Shooter.ShooterId == x.ShooterId);
                if (SelectedShooter == null)
                {
                    SelectedShooter = Shooters.FirstOrDefault();
                }
            });

            MessengerInstance.Register <RefreshDataFromRepositoriesMessage>(this,
                                                                            x =>
            {
                UiPerson selectedPerson          = SelectedPerson;
                ShooterViewModel selectedShooter = SelectedShooter;
                LoadPersons();

                if (selectedPerson != null)
                {
                    MessengerInstance.Send(new SetSelectedPersonMessage(selectedPerson.PersonId));
                }

                if (selectedShooter != null)
                {
                    MessengerInstance.Send(new SetSelectedShooterMessage(selectedShooter.Shooter.ShooterId));
                }
            });
        }
    public PersonEditViewModel()
    {
      EditPersonCommand = new RelayCommand<UiPerson>(ExecuteEditPersonCommand, CanExecuteEditPersonCommand);
      CancelCommand = new RelayCommand<object>(ExecuteCloseCommand);
      //CreateShooterCommand = new RelayCommand<UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand);

      if (!DesignTimeHelper.IsInDesignMode)
      {
        IConfiguration config = ConfigurationSource.Configuration;
        _personDataStore = config.GetPersonDataStore();
        _shooterDataStore = config.GetShooterDataStore();
        _uiEvents = config.GetUIEvents();
        _windowService = config.GetWindowService();
        _shooterNumberService = config.GetShooterNumberService();
        _uiEvents.PersonSelected += person => { UiPerson = person ?? new UiPerson(); };
        _uiEvents.RequireSelectedPerson();
      }
    }
Beispiel #23
0
        public PersonEditViewModel()
        {
            EditPersonCommand = new RelayCommand <UiPerson>(ExecuteEditPersonCommand, CanExecuteEditPersonCommand);
            CancelCommand     = new RelayCommand <object>(ExecuteCloseCommand);
            //CreateShooterCommand = new RelayCommand<UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand);

            if (!DesignTimeHelper.IsInDesignMode)
            {
                IConfiguration config = ConfigurationSource.Configuration;
                _personDataStore          = config.GetPersonDataStore();
                _shooterDataStore         = config.GetShooterDataStore();
                _uiEvents                 = config.GetUIEvents();
                _windowService            = config.GetWindowService();
                _shooterNumberService     = config.GetShooterNumberService();
                _uiEvents.PersonSelected += person => { UiPerson = person ?? new UiPerson(); };
                _uiEvents.RequireSelectedPerson();
            }
        }
Beispiel #24
0
        private void RegisterEditPersonDialog(IPersonDataStore personDataStore)
        {
            _messenger.Register <EditPersonDialogMessage>(this,
                                                          x =>
            {
                Person p = personDataStore.FindById(x.PersonId);
                var m    = new CreatePersonViewModel()
                {
                    Title       = "Person editieren",
                    PersonId    = p.PersonId,
                    FirstName   = p.FirstName,
                    LastName    = p.LastName,
                    DateOfBirth = p.DateOfBirth,
                    Address     = p.Address,
                    City        = p.City,
                    ZipCode     = p.ZipCode,
                    Email       = p.Email,
                    Phone       = p.Phone
                };

                IWindow w   = _vs.ExecuteFunction <CreatePersonViewModel, IWindow>((IWindow)Current.MainWindow, m);
                bool?result = w.ShowDialog();
                if (!result.HasValue || !result.Value)
                {
                    return;
                }

                personDataStore.Update(new Person
                {
                    PersonId    = m.PersonId,
                    FirstName   = m.FirstName,
                    LastName    = m.LastName,
                    DateOfBirth = m.DateOfBirth,
                    Address     = m.Address,
                    City        = m.City,
                    ZipCode     = m.ZipCode,
                    Email       = m.Email,
                    Phone       = m.Phone
                });

                _messenger.Send(new RefreshDataFromRepositoriesMessage());
                _messenger.Send(new SetSelectedPersonMessage(m.PersonId));
            });
        }
        public void Initialize()
        {
            _personDataStore = ServiceLocator.Current.GetInstance<IPersonDataStore>();
            _shooterDataStore = ServiceLocator.Current.GetInstance<IShooterDataStore>();
            _shooterNumberService = ServiceLocator.Current.GetInstance<IShooterNumberService>();
            _shooterDataWriter = ServiceLocator.Current.GetInstance<ISsvShooterDataWriterService>();
            _collectionShooterDataStore = ServiceLocator.Current.GetInstance<ICollectionShooterDataStore>();
            _shooterCollectionDataStore = ServiceLocator.Current.GetInstance<IShooterCollectionDataStore>();
            _serviceDeskConfiguration = ServiceLocator.Current.GetInstance<ServiceDeskConfiguration>();

            MessengerInstance.Register<PersonSelectedMessage>(this,
                x =>
                {
                    UpdateCommandCanExecuteOnSelectedPersonChanged();
                    LoadShooters(x.PersonId);
                });
            MessengerInstance.Register<SetSelectedPersonMessage>(this,
                x =>
                {
                    SelectedPerson = FilteredPersons.FirstOrDefault(person => person.PersonId == x.PersonId);
                });
            MessengerInstance.Register<SetSelectedShooterMessage>(this,
                x =>
                {
                    SelectedShooter = Shooters.FirstOrDefault(s => s.Shooter.ShooterId == x.ShooterId);
                    if (SelectedShooter == null)
                        SelectedShooter = Shooters.FirstOrDefault();
                });

            MessengerInstance.Register<RefreshDataFromRepositoriesMessage>(this,
                x =>
                {
                    UiPerson selectedPerson = SelectedPerson;
                    ShooterViewModel selectedShooter = SelectedShooter;
                    LoadPersons();

                    if (selectedPerson != null)
                        MessengerInstance.Send(new SetSelectedPersonMessage(selectedPerson.PersonId));

                    if (selectedShooter != null)
                        MessengerInstance.Send(new SetSelectedShooterMessage(selectedShooter.Shooter.ShooterId));
                });
        }
    public PersonCreateViewModel()
    {
      CreatePersonCommand = new RelayCommand<UiPerson>(ExecuteCreatePersonCommand, CanExecuteCreatePersonCommand);
      CancelCommand = new RelayCommand<object>(ExecuteCloseCommand);
      //CreateShooterCommand = new RelayCommand<UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand);
      //InscribeCompetitionCommand = new RelayCommand<UiShooter>(ExecuteInscribeCompetitionCommand, CanExecuteInscribeCompoetitionCommand);

      if (!DesignTimeHelper.IsInDesignMode)
      {
        IConfiguration config = ConfigurationSource.Configuration;
        _personDataStore = config.GetPersonDataStore();
        _shooterDataStore = config.GetShooterDataStore();
        _uiEvents = config.GetUIEvents();
        _windowService = config.GetWindowService();
        //_shooterNumberService = config.GetShooterNumberService();
      }

      UiPerson = new UiPerson();
    }
Beispiel #27
0
        public PersonCreateViewModel()
        {
            CreatePersonCommand = new RelayCommand <UiPerson>(ExecuteCreatePersonCommand, CanExecuteCreatePersonCommand);
            CancelCommand       = new RelayCommand <object>(ExecuteCloseCommand);
            //CreateShooterCommand = new RelayCommand<UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand);
            //InscribeCompetitionCommand = new RelayCommand<UiShooter>(ExecuteInscribeCompetitionCommand, CanExecuteInscribeCompoetitionCommand);

            if (!DesignTimeHelper.IsInDesignMode)
            {
                IConfiguration config = ConfigurationSource.Configuration;
                _personDataStore  = config.GetPersonDataStore();
                _shooterDataStore = config.GetShooterDataStore();
                _uiEvents         = config.GetUIEvents();
                _windowService    = config.GetWindowService();
                //_shooterNumberService = config.GetShooterNumberService();
            }

            UiPerson = new UiPerson();
        }
        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);
        }
Beispiel #29
0
 public TestController(IPersonDataStore personDataStore) => _personDataStore = personDataStore;
    public static UiParticipation FetchShooters(this UiParticipation participation,
      IShooterCollectionParticipationDataStore shooterCollectionParticipationDataStore,
      IShooterCollectionDataStore shooterCollectionDataStore,
      ICollectionShooterDataStore collectionShooterDataStore,
      IShooterDataStore shooterDataStore,
      IPersonDataStore personDataStore)
    {
      participation.ShooterCollections = new List<UiShooterCollection>();
      List<ShooterCollectionParticipation> shooterCollectionParticipations =
        shooterCollectionParticipationDataStore.FindByIdParticipationId(participation.ParticipationId).ToList();
      List<ShooterCollection> shooterCollections = shooterCollectionParticipations.Select(_ => shooterCollectionDataStore.FindById(_.ShooterCollectionId)).ToList();

      foreach (ShooterCollection shooterCollection in shooterCollections)
      {
        List<CollectionShooter> collectionShooters =
          collectionShooterDataStore.FindByShooterCollectionId(shooterCollection.ShooterCollectionId).ToList();

        participation.ShooterCollections.Add(new UiShooterCollection
        {
          CollectionName = shooterCollection.CollectionName,
          ShooterCollectionId = shooterCollection.ShooterCollectionId,
          Shooters = collectionShooters.Select(_ => ToUiShooter(shooterDataStore.FindById(_.ShooterId)).FetchPerson(personDataStore))
        });
      }

      return participation;
    }
Beispiel #31
0
        private void RegisterCreatePersonDialog(IPersonDataStore personDataStore)
        {
            _messenger.Register<CreatePersonDialogMessage>(this,
                x =>
                {
                    var m = new CreatePersonViewModel
                    {
                        Title = "Person erstellen"
                    };
                    IWindow w = _vs.ExecuteFunction<CreatePersonViewModel, IWindow>((IWindow) Current.MainWindow, m);
                    bool? result = w.ShowDialog();
                    if (!result.HasValue || !result.Value) return;

                    Person person = new Person
                    {
                        FirstName = m.FirstName,
                        LastName = m.LastName,
                        DateOfBirth = m.DateOfBirth,
                        Address = m.Address,
                        City = m.City,
                        ZipCode = m.ZipCode,
                        Email = m.Email,
                        Phone = m.Phone
                    };
                    personDataStore.Create(person);
                    _messenger.Send(new RefreshDataFromRepositoriesMessage());
                    _messenger.Send(new SetSelectedPersonMessage(person.PersonId));
                });
        }
Beispiel #32
0
        private void RegisterEditPersonDialog(IPersonDataStore personDataStore)
        {
            _messenger.Register<EditPersonDialogMessage>(this,
                x =>
                {
                    Person p = personDataStore.FindById(x.PersonId);
                    var m = new CreatePersonViewModel()
                    {
                        Title = "Person editieren",
                        PersonId = p.PersonId,
                        FirstName = p.FirstName,
                        LastName = p.LastName,
                        DateOfBirth = p.DateOfBirth,
                        Address = p.Address,
                        City = p.City,
                        ZipCode = p.ZipCode,
                        Email = p.Email,
                        Phone = p.Phone
                    };

                    IWindow w = _vs.ExecuteFunction<CreatePersonViewModel, IWindow>((IWindow) Current.MainWindow, m);
                    bool? result = w.ShowDialog();
                    if (!result.HasValue || !result.Value) return;

                    personDataStore.Update(new Person
                    {
                        PersonId = m.PersonId,
                        FirstName = m.FirstName,
                        LastName = m.LastName,
                        DateOfBirth = m.DateOfBirth,
                        Address = m.Address,
                        City = m.City,
                        ZipCode = m.ZipCode,
                        Email = m.Email,
                        Phone = m.Phone
                    });

                    _messenger.Send(new RefreshDataFromRepositoriesMessage());
                    _messenger.Send(new SetSelectedPersonMessage(m.PersonId));
                });
        }
Beispiel #33
0
        private void RegisterDeletePersonDialog(IPersonDataStore personDataStore)
        {
            _messenger.Register<DeletePersonDialogMessage>(this,
                x =>
                {
                    YesNoMessageBoxViewModel vm = new YesNoMessageBoxViewModel
                    {
                        DefaultYes = false,
                        Caption = "Person löschen?",
                        Message =
                            string.Format("Möchtest du die Person '{0} {1}' wirklich löschen?",
                                x.FirstName,
                                x.LastName)
                    };

                    IWindow w = _vs.ExecuteFunction<YesNoMessageBoxViewModel, IWindow>((IWindow) Current.MainWindow, vm);
                    bool? result = w.ShowDialog();
                    if (!result.HasValue || !result.Value) return;

                    Person person = personDataStore.FindById(x.PersonId);
                    personDataStore.Delete(person);
                    _messenger.Send(new RefreshDataFromRepositoriesMessage());
                });
        }
Beispiel #34
0
        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);
        }