private void OnSalaryAdded(SalaryAddedMessage message) { EditableSalaryViewModel salaryViewModel = new EditableSalaryViewModel(salaryValidator); salaryViewModel.LoadEntity(message.Content); Salaries.Add(salaryViewModel); exportCommand.RaiseCanExecuteChanged(); }
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(); }
private async void Add() { await editableSalaryViewModel.ValidateAllAsync(); if (!editableSalaryViewModel.HasErrors) { Salary salary = EditableSalaryViewModel.CreateEntity(); MessengerInstance.Send(new SalaryAddedMessage(this, salary)); editableSalaryViewModel.Clear(); } }
private void AddSalaries(IEnumerable <Salary> importedCollection) { foreach (var item in importedCollection) { EditableSalaryViewModel itemViewModel = new EditableSalaryViewModel(salaryValidator); itemViewModel.LoadEntity(item); Salaries.Add(itemViewModel); } exportCommand.RaiseCanExecuteChanged(); }
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; }
/// <summary> /// Design-time constructor /// </summary> public EditSalaryViewModel() { editableSalaryViewModel = new EditableSalaryViewModel(); }