예제 #1
0
        public AddOperationViewModel(Action discardAction, Action <string> saveAction, IRecordIdGenerator recordIdGenerator, IFileIdGenerator fileIdGenerator, ISafe safe)
        {
            Record = new RecordViewModel(CreateEmptyRecord(recordIdGenerator.GetRecordId()), safe, fileIdGenerator);
            Record.PropertyChanged += (sender, args) =>
            {
                CanExecuteSaveCommand = !string.IsNullOrWhiteSpace(Record.Name);
            };

            DiscardCommand = new DelegateCommand
                                 (() =>
            {
                safe.ReorganizeFiles(Record.Id);
                discardAction.Invoke();
            }
                                 );

            SaveCommand = new DelegateCommand(() =>
            {
                var record = Record.GetRecord();
                safe.UpsertRecord(record);
                safe.ReorganizeFiles(Record.Id);
                saveAction.Invoke(Record.Id);
            }, () => CanExecuteSaveCommand);
        }
 private void Save()
 {
     _safe.UpsertRecord(Record.GetRecord());
     _safe.ReorganizeFiles(_recordId);
     _reloadAction.Invoke();
 }