Exemplo n.º 1
0
        private void OnSalaryAdded(SalaryAddedMessage message)
        {
            EditableSalaryViewModel salaryViewModel = new EditableSalaryViewModel(salaryValidator);

            salaryViewModel.LoadEntity(message.Content);
            Salaries.Add(salaryViewModel);
            exportCommand.RaiseCanExecuteChanged();
        }
Exemplo n.º 2
0
        public AddSalaryViewModel(EditableSalaryViewModel editableSalaryViewModel)
        {
            this.editableSalaryViewModel = editableSalaryViewModel;
            addCommand = new RelayCommand(Add);

            editableSalaryViewModelObserver = new PropertyObserver <EditableSalaryViewModel>(EditableSalaryViewModel);
            editableSalaryViewModelObserver.RegisterHandler(x => x.HasErrors, x => RefreshCommands());
            EditableSalaryViewModel.Validate();
        }
Exemplo n.º 3
0
        private async void Add()
        {
            await editableSalaryViewModel.ValidateAllAsync();

            if (!editableSalaryViewModel.HasErrors)
            {
                Salary salary = EditableSalaryViewModel.CreateEntity();
                MessengerInstance.Send(new SalaryAddedMessage(this, salary));
                editableSalaryViewModel.Clear();
            }
        }
Exemplo n.º 4
0
        private void AddSalaries(IEnumerable <Salary> importedCollection)
        {
            foreach (var item in importedCollection)
            {
                EditableSalaryViewModel itemViewModel = new EditableSalaryViewModel(salaryValidator);
                itemViewModel.LoadEntity(item);
                Salaries.Add(itemViewModel);
            }

            exportCommand.RaiseCanExecuteChanged();
        }
Exemplo n.º 5
0
        public EditSalaryViewModel(INavigationService navigationService,
                                   EditableSalaryViewModel editableSalary)
        {
            this.navigationService  = navigationService;
            editableSalaryViewModel = editableSalary;

            editableSalary.BeginEdit();

            saveCommand    = new RelayCommand(Save, CanSave);
            _cancelCommand = new RelayCommand(Cancel);

            EditableSalaryViewModel.PropertyChanged += ViewModelPropertyChanged;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Design-time constructor
 /// </summary>
 public EditSalaryViewModel()
 {
     editableSalaryViewModel = new EditableSalaryViewModel();
 }