private void CreateShooter(UiPerson person)
        {
            if (person != null)
            {
                int     shooterNumber = _shooterNumberService.GetShooterNumber();
                Shooter shooter       = new Shooter
                {
                    PersonId      = person.PersonId,
                    ShooterNumber = shooterNumber
                };

                _shooterDataWriter.WriteShooterData(new SsvShooterData
                {
                    FirstName     = person.FirstName,
                    LastName      = person.LastName,
                    LicenseNumber = (uint)shooter.ShooterNumber
                });

                _shooterDataStore.Create(shooter);

                MessengerInstance.Send(new RefreshDataFromRepositoriesMessage());
                MessengerInstance.Send(new SetSelectedPersonMessage(person.PersonId));
                MessengerInstance.Send(new SetSelectedShooterMessage(shooter.ShooterId));
            }
        }
        public void LoadPersons()
        {
            UiPerson selectedPerson = SelectedPerson;

            AllPersons = (from p in _personDataStore.GetAll()
                          join s in _shooterDataStore.GetAll() on p.PersonId equals s.PersonId into gj
                          orderby p.FirstName
                          orderby p.LastName
                          from subs in gj.DefaultIfEmpty()
                          group gj by p
                          into grouping
                          select new UiPerson
            {
                PersonId = grouping.Key.PersonId,
                FirstName = grouping.Key.FirstName,
                LastName = grouping.Key.LastName,
                DateOfBirth = grouping.Key.DateOfBirth,
                HasShooters = grouping.SelectMany(x => x).Any()
            }).ToList();

            FilterPersons();

            if (selectedPerson != null)
            {
                SelectedPerson = FilteredPersons.FirstOrDefault(x => selectedPerson.PersonId == x.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));
                }
            });
        }
        private void CreateShooter(UiPerson person)
        {
            if (person != null)
            {
                int shooterNumber = _shooterNumberService.GetShooterNumber();
                Shooter shooter = new Shooter
                {
                    PersonId = person.PersonId,
                    ShooterNumber = shooterNumber
                };

                _shooterDataWriter.WriteShooterData(new SsvShooterData
                {
                    FirstName = person.FirstName,
                    LastName = person.LastName,
                    LicenseNumber = (uint) shooter.ShooterNumber
                });

                _shooterDataStore.Create(shooter);

                MessengerInstance.Send(new RefreshDataFromRepositoriesMessage());
                MessengerInstance.Send(new SetSelectedPersonMessage(person.PersonId));
                MessengerInstance.Send(new SetSelectedShooterMessage(shooter.ShooterId));
            }
        }