private void ExecuteAddCommand(string obj)
        {
            ShooterCollection sc = new ShooterCollection
            {
                CollectionName = obj
            };

            _shooterCollectionDataStore.Create(sc);

            UiEventsDelegate <UiParticipation> handler = _uiEvents.FetchSelectedParticipation;

            if (handler != null)
            {
                UiParticipation p = handler();
                if (p != null)
                {
                    ShooterCollectionParticipation scp = new ShooterCollectionParticipation
                    {
                        ParticipationId     = p.ParticipationId,
                        ShooterCollectionId = sc.ShooterCollectionId
                    };
                    _shooterCollectionParticipationDataStore.Create(scp);
                }
            }

            _windowService.CloseTextBoxInputDialog();
        }
        public void Update(ShooterCollection shooterCollection)
        {
            t_shootercollection entity = _sqlRepository.Find(_ => _.ShooterCollectionId == shooterCollection.ShooterCollectionId).Single();

            entity.UpdateEntity(shooterCollection);
            _sqlRepository.Commit();
        }
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());
            });
        }
Exemplo n.º 4
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.º 5
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.º 6
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);
        }
        public void Create(ShooterCollection shooter)
        {
            t_shootercollection entity = new t_shootercollection();

            entity.UpdateEntity(shooter);
            _sqlRepository.Insert(entity);
            shooter.ShooterCollectionId = entity.ShooterCollectionId;
        }
 public void Add(Person person, decimal score, ShooterCollection shooterCollection)
 {
     if (!_shooterCollectionNames.ContainsKey(shooterCollection.ShooterCollectionId))
     {
         _shooterCollectionNames.Add(shooterCollection.ShooterCollectionId, shooterCollection.CollectionName);
     }
     _rankItems.Add(new Tuple <Person, decimal, int>(person, score, shooterCollection.ShooterCollectionId));
 }
        private void ExecuteCreateParticipationCommand(ParticipationDraft participationDraft)
        {
            ShooterCollection shooterCollection = new ShooterCollection
            {
                CollectionName = participationDraft.ParticipationName
            };

            _shooterCollectionDataStore.Create(shooterCollection);

            ShooterCollectionParticipation collectionParticipation = new ShooterCollectionParticipation
            {
                ParticipationId     = participationDraft.ParticipationType.ParticipationTypeId,
                ShooterCollectionId = shooterCollection.ShooterCollectionId
            };

            _shooterCollectionParticipationDataStore.Create(collectionParticipation);
            _windowService.CloseCreateParticipationWindow();
        }
 public static t_shootercollection UpdateEntity(this t_shootercollection entity, ShooterCollection shooterCollection)
 {
     entity.CollectionName = shooterCollection.CollectionName;
     entity.ProgramNumber  = shooterCollection.ProgramNumber;
     return(entity);
 }
        public void Delete(ShooterCollection shooterCollection)
        {
            t_shootercollection entity = _sqlRepository.Find(_ => _.ShooterCollectionId == shooterCollection.ShooterCollectionId).Single();

            _sqlRepository.Delete(entity);
        }
        public ShooterCollection FindById(int id)
        {
            ShooterCollection result = _sqlRepository.Find(_ => _.ShooterCollectionId == id).Select(_selector).Single();

            return(result);
        }