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();
    }
 private bool CanExecuteCreatePersonCommand(UiPerson uiPerson)
 {
   return (uiPerson != null && !string.IsNullOrWhiteSpace(uiPerson.FirstName) && !string.IsNullOrWhiteSpace(uiPerson.LastName));
 }
 private void ExecuteCreatePersonCommand(UiPerson uiPerson)
 {
   Person p = uiPerson.ToPerson();
   _personDataStore.Create(p);
   _uiEvents.PersonDataStoreChanged();
   _windowService.CloseCreatePersonWindow();
   _uiEvents.SelectPersonById(p.PersonId);
 }
Exemplo n.º 4
0
 private void OnSelectedPersonItemChanged(UiPerson selectedUiPerson)
 {
   LoadShooterList();
   LoadParticipationList();
   SelectFirstShooter();
 }
 private void ExecuteEditPersonCommand(UiPerson uiPerson)
 {
   _personDataStore.Update(uiPerson.ToPerson());
   _uiEvents.PersonDataStoreChanged();
   _windowService.CloseEditPersonWindow();
 }
Exemplo n.º 6
0
 private bool CanExecuteCreateShooterCommand(UiPerson uiPerson)
 {
   return uiPerson != null;
 }
Exemplo n.º 7
0
    private void ExecuteCreateShooterCommand(UiPerson uiPerson)
    {
      try
      {
        Shooter shooter = new Shooter();
        shooter.ShooterNumber = _shooterNumberService.GetShooterNumber();
        shooter.PersonId = uiPerson.PersonId;
        _shooterDataStore.Create(shooter);
        _shooterDataWriterService.WriteShooterData(new SsvShooterData
        {
          FirstName = uiPerson.FirstName,
          LastName = uiPerson.LastName,
          LicenseNumber = (uint)shooter.ShooterNumber
        });
        _windowService.ShowMessage("Schütze erstellt", string.Format("Schütze mit Schützennummer '{0}' erfolgreich erstellt.", shooter.ShooterNumber));
      }
      catch (Exception e)
      {
        ReportException(e);
        _shooterDataStore.Revert();
      }
      finally
      {
        _uiEvents.ShooterDataStoreChanged();
      }

      //try
      //{
      //  _windowService.ShowCreateShooterWindow();
      //}
      //catch (Exception e)
      //{
      //  ReportException(e);
      //}
    }
Exemplo n.º 8
0
    private void ExecuteDeletePersonCommand(UiPerson uiPerson)
    {
      try
      {
        bool yes = _windowService.ShowYesNoMessasge("Person löschen",
          string.Format("Möchtest du die Person '{0} {1}' wirklich löschen?", uiPerson.LastName, uiPerson.FirstName));

        if (yes)
        {
          _personDataStore.Delete(uiPerson.ToPerson());
        }
      }
      catch (Exception e)
      {
        ReportException(e);
        _personDataStore.Revert();
      }
      finally
      {
        _uiEvents.PersonDataStoreChanged();
      }
    }
Exemplo n.º 9
0
 private bool CanExecuteDeletePersonCommand(UiPerson uiPerson)
 {
   return uiPerson != null;
 }
Exemplo n.º 10
0
 private void ExecuteEditPersonCommand(UiPerson uiPerson)
 {
   try
   {
     _windowService.ShowEditPersonWindow();
   }
   catch (Exception e)
   {
     ReportException(e);
   }
 }
Exemplo n.º 11
0
 private bool CanExecuteEditPersonCommand(UiPerson uiPerson)
 {
   return uiPerson != null;
 }
 private void ExecuteCreateShooterCommand(UiPerson uiPerson)
 {
   //try
   //{
   //  Shooter shooter = new Shooter();
   //  shooter.ShooterNumber = _shooterNumberService.GetShooterNumber();
   //  shooter.PersonId = uiPerson.PersonId;
   //  _shooterDataStore.Create(shooter);
   //  _ssvShooterDataWriterService.WriteShooterData(new SsvShooterData
   //  {
   //    FirstName = uiPerson.FirstName,
   //    CurrentShooterLabel = uiPerson.CurrentShooterLabel,
   //    LicenseNumber = (uint)shooter.ShooterNumber
   //  });
   //  UiShooter = UiBusinessObjectMapper.ToUiShooter(_shooterDataStore.FindByShooterNumber(shooter.ShooterNumber));
   //}
   //catch (Exception e)
   //{
   //  ReportException(e);
   //  _shooterDataStore.Revert();
   //}
   //finally
   //{
   //  _uiEvents.ShooterDataStoreChanged();
   //}
 }