Exemplo n.º 1
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");
        }
    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);
    }
Exemplo n.º 3
0
        private void RegisterDeleteGroupingDialog(IShooterCollectionDataStore shooterCollectionDataStore)
        {
            _messenger.Register <DeleteGroupingDialogMessage>(this,
                                                              x =>
            {
                YesNoMessageBoxViewModel vm = new YesNoMessageBoxViewModel
                {
                    Caption = "Gruppierung löschen",
                    Message =
                        string.Format("Wollen Sie die Gruppierung '{0}' wirklich löschen?",
                                      x.CollectionName)
                };

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

                ShooterCollection sc = shooterCollectionDataStore.FindById(x.ShooterCollectionId);
                shooterCollectionDataStore.Delete(sc);
                _messenger.Send(new RefreshDataFromRepositoriesMessage());
            });
        }
        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));
            }
        }
Exemplo n.º 5
0
        private RankingReport BuildCollectionRankingReport()
        {
            IShooterCollectionDataStore shooterCollectionDataStore =
                ServiceLocator.Current.GetInstance <IShooterCollectionDataStore>();
            ICollectionShooterDataStore collectionShooterDataStore =
                ServiceLocator.Current.GetInstance <ICollectionShooterDataStore>();

            CollectionRankingReport report = new CollectionRankingReport();
            int progamNumber = _rankingConfiguration.ProgramNumber;
            IEnumerable <Tuple <Person, int, decimal, decimal> > bestResults = GetBestResults(progamNumber);

            foreach (Tuple <Person, int, decimal, decimal> result in bestResults)
            {
                int shooterId = result.Item2;
                ShooterCollection shooterCollection = (from sc in shooterCollectionDataStore.GetAll()
                                                       join cs in collectionShooterDataStore.GetAll() on sc.ShooterCollectionId equals
                                                       cs.ShooterCollectionId
                                                       where cs.ShooterId == shooterId && sc.ProgramNumber == progamNumber
                                                       select sc).FirstOrDefault();

                if (shooterCollection != null)
                {
                    report.Add(result.Item1, result.Item3, shooterCollection);
                }
            }

            return(report);
        }
Exemplo n.º 6
0
        private void RegisterCreateGroupingDialog(IShooterCollectionDataStore shooterCollectionDataStore, ServiceDeskConfiguration serviceDeskConfiguration)
        {
            _messenger.Register <CreateGroupingDialogMessage>(this,
                                                              x =>
            {
                var m = new CreateGroupingViewModel(serviceDeskConfiguration)
                {
                    Title = "Gruppierung erstellen"
                };

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

                ShooterCollection sc = new ShooterCollection
                {
                    CollectionName = m.GroupingName,
                    ProgramNumber  = int.Parse(m.SelectedParticipation.ProgramNumber)
                };

                shooterCollectionDataStore.Create(sc);
                _messenger.Send(new RefreshDataFromRepositoriesMessage());
            });
        }
Exemplo n.º 7
0
        private void RegisterEditGroupingDialog(IShooterCollectionDataStore shooterCollectionDataStore)
        {
            _messenger.Register <EditGroupingDialogMessage>(this,
                                                            x =>
            {
                var m = new EditGroupingViewModel
                {
                    GroupingName = x.GroupingName,
                    GroupingId   = x.GroupingId,
                    Title        = "Gruppenname ändern"
                };

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

                ShooterCollection sc = shooterCollectionDataStore.FindById(m.GroupingId);
                sc.CollectionName    = m.GroupingName;
                shooterCollectionDataStore.Update(sc);

                _messenger.Send(new RefreshDataFromRepositoriesMessage());
            });
        }
 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");
 }
        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 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);
        }
Exemplo n.º 11
0
        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 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);
        }
        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 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));
      }
    }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
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 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 TextBoxInputViewModel()
    {
      if (!DesignTimeHelper.IsInDesignMode)
      {
        IConfiguration config = ConfigurationSource.Configuration;
        _shooterCollectionDataStore = config.GetShooterCollectionDataStore();
        _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore();
        _uiEvents = config.GetUIEvents();
        _windowService = config.GetWindowService();
      }

      AddCommand = new RelayCommand<string>(ExecuteAddCommand, CanExecuteAddCommand);
      CancelCommand = new RelayCommand<object>((_) => _windowService.CloseTextBoxInputDialog());
    }
Exemplo n.º 19
0
        public TextBoxInputViewModel()
        {
            if (!DesignTimeHelper.IsInDesignMode)
            {
                IConfiguration config = ConfigurationSource.Configuration;
                _shooterCollectionDataStore = config.GetShooterCollectionDataStore();
                _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore();
                _uiEvents      = config.GetUIEvents();
                _windowService = config.GetWindowService();
            }

            AddCommand    = new RelayCommand <string>(ExecuteAddCommand, CanExecuteAddCommand);
            CancelCommand = new RelayCommand <object>((_) => _windowService.CloseTextBoxInputDialog());
        }
Exemplo n.º 20
0
        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 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 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);
        }
    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;
    }
Exemplo n.º 24
0
        private void RegisterCreateGroupingDialog(IShooterCollectionDataStore shooterCollectionDataStore, ServiceDeskConfiguration serviceDeskConfiguration)
        {
            _messenger.Register<CreateGroupingDialogMessage>(this,
                x =>
                {
                    var m = new CreateGroupingViewModel(serviceDeskConfiguration)
                    {
                        Title = "Gruppierung erstellen"
                    };

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

                    ShooterCollection sc = new ShooterCollection
                    {
                        CollectionName = m.GroupingName,
                        ProgramNumber = int.Parse(m.SelectedParticipation.ProgramNumber)
                    };

                    shooterCollectionDataStore.Create(sc);
                    _messenger.Send(new RefreshDataFromRepositoriesMessage());
                });
        }
Exemplo n.º 25
0
        private void RegisterEditGroupingDialog(IShooterCollectionDataStore shooterCollectionDataStore)
        {
            _messenger.Register<EditGroupingDialogMessage>(this,
                x =>
                {
                    var m = new EditGroupingViewModel
                    {
                        GroupingName = x.GroupingName,
                        GroupingId = x.GroupingId,
                        Title = "Gruppenname ändern"
                    };

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

                    ShooterCollection sc = shooterCollectionDataStore.FindById(m.GroupingId);
                    sc.CollectionName = m.GroupingName;
                    shooterCollectionDataStore.Update(sc);

                    _messenger.Send(new RefreshDataFromRepositoriesMessage());
                });
        }
Exemplo n.º 26
0
        private void RegisterDeleteGroupingDialog(IShooterCollectionDataStore shooterCollectionDataStore)
        {
            _messenger.Register<DeleteGroupingDialogMessage>(this,
                x =>
                {
                    YesNoMessageBoxViewModel vm = new YesNoMessageBoxViewModel
                    {
                        Caption = "Gruppierung löschen",
                        Message =
                            string.Format("Wollen Sie die Gruppierung '{0}' wirklich löschen?",
                                x.CollectionName)
                    };

                    IWindow w = _vs.ExecuteFunction<YesNoMessageBoxViewModel, IWindow>((IWindow) Current.MainWindow, vm);
                    bool? result = w.ShowDialog();
                    if (!result.HasValue || !result.Value) return;
                    
                    ShooterCollection sc = shooterCollectionDataStore.FindById(x.ShooterCollectionId);
                    shooterCollectionDataStore.Delete(sc);
                    _messenger.Send(new RefreshDataFromRepositoriesMessage());
                });
        }