Пример #1
0
        private void OnSalaryAdded(SalaryAddedMessage message)
        {
            EditableSalaryViewModel salaryViewModel = new EditableSalaryViewModel(salaryValidator);

            salaryViewModel.LoadEntity(message.Content);
            Salaries.Add(salaryViewModel);
            exportCommand.RaiseCanExecuteChanged();
        }
Пример #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();
        }
Пример #3
0
        private async void Add()
        {
            await editableSalaryViewModel.ValidateAllAsync();

            if (!editableSalaryViewModel.HasErrors)
            {
                Salary salary = EditableSalaryViewModel.CreateEntity();
                MessengerInstance.Send(new SalaryAddedMessage(this, salary));
                editableSalaryViewModel.Clear();
            }
        }
Пример #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();
        }
Пример #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;
        }
Пример #6
0
 /// <summary>
 /// Design-time constructor
 /// </summary>
 public EditSalaryViewModel()
 {
     editableSalaryViewModel = new EditableSalaryViewModel();
 }