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));
        }
        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)
                );
        }
Ejemplo n.º 4
0
 private void LoadPersonList()
 {
     try
     {
         UiPeople =
             new ObservableCollection <UiPerson>(
                 _personDataStore.GetAll().Select(UiBusinessObjectMapper.ToUiPerson).OrderBy(_ => _.LastName));
     }
     catch (Exception e)
     {
         ReportException(e);
     }
 }
Ejemplo n.º 5
0
        private void LoadPersons()
        {
            IEnumerable <PersonShooterViewModel> shooters = from shooter in _shooterDataStore.GetAll()
                                                            join person in _personDataStore.GetAll() on shooter.PersonId equals person.PersonId
                                                            orderby person.FirstName
                                                            orderby person.LastName
                                                            select new PersonShooterViewModel
            {
                FirstName     = person.FirstName,
                LastName      = person.LastName,
                DateOfBirth   = person.DateOfBirth,
                PersonId      = person.PersonId,
                ShooterId     = shooter.ShooterId,
                ShooterNumber = shooter.ShooterNumber
            };

            AllPersons = shooters.ToList();
            UpdateFilteredPersons();
        }
        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);
        }
Ejemplo n.º 7
0
        private void PrintBarcode()
        {
            if (SelectedShooter != null)
            {
                var personShooter = (from shooter in _shooterDataStore.GetAll()
                                     join person in _personDataStore.GetAll() on shooter.PersonId equals person.PersonId
                                     where shooter.ShooterId == SelectedShooter.Shooter.ShooterId
                                     select new
                {
                    person.FirstName,
                    person.LastName,
                    person.DateOfBirth,
                    shooter.ShooterNumber
                }).Single();

                IBarcodeBuilderService barcodeBuilderService = ServiceLocator.Current.GetInstance <IBarcodeBuilderService>();
                string barcode = barcodeBuilderService.BuildBarcode(personShooter.ShooterNumber, 0);


                var shooterCollections = from sc in _shooterCollectionDataStore.GetAll()
                                         join cs in _collectionShooterDataStore.GetAll() on
                                         sc.ShooterCollectionId equals cs.ShooterCollectionId
                                         join p in _serviceDeskConfiguration.ParticipationDescriptions.GetAll() on
                                         sc.ProgramNumber.ToString() equals p.ProgramNumber
                                             where p.AllowShooterCollectionParticipation && cs.ShooterId == SelectedShooter.Shooter.ShooterId
                                         select new
                {
                    sc.CollectionName,
                    p.ProgramName,
                    p.ProgramNumber
                };

                Dictionary <string, Tuple <string, string> > grouped = (from sc in shooterCollections
                                                                        group sc by sc.ProgramNumber
                                                                        into g
                                                                        select new
                {
                    ProgramNumber = g.Key,
                    CollectionName = g.Single().CollectionName,
                    ProgramName = g.Single().ProgramName
                }).ToDictionary(x => x.ProgramNumber,
                                x => new Tuple <string, string>(x.ProgramName, x.CollectionName));

                IBarcodePrintService barcodeService = ServiceLocator.Current.GetInstance <IBarcodePrintService>();

                GenericBarcode_20150909 genericBarcode = new GenericBarcode_20150909
                {
                    FirstName   = personShooter.FirstName,
                    LastName    = personShooter.LastName,
                    DateOfBirth = personShooter.DateOfBirth,
                    Barcode     = barcode,
                    ParticipationTypeToCollectionName = grouped.Values.Take(2).ToList(),
                    Participations = _serviceDeskConfiguration.ParticipationDescriptions.GetAll().Select(x => x.ProgramName).Take(5).ToList()
                };

                try
                {
                    barcodeService.Print(genericBarcode);
                }
                catch (Exception e)
                {
                    MessengerInstance.Send(new DialogMessage("Barcode Print Error",
                                                             "Fehler beim Drucken des Barcodes.\r\n\r\n" + e.ToString(),
                                                             MessageIcon.Error));
                }
            }
        }