public WordsUnitBatchAddViewModel(WordsUnitViewModel vm) { var item = vm.NewUnitWord(); item.CopyProperties(ItemEdit); ItemEdit.Save = ReactiveCommand.CreateFromTask(async() => { ItemEdit.CopyProperties(item); var words = ItemEdit.WORDS.Split('\n').Select(s => s.Trim()).ToList(); foreach (var s in words) { item.WORD = vm.vmSettings.AutoCorrectInput(s); await vm.Create(item); item.SEQNUM++; } }); }
public WordsUnitDetailViewModel(WordsUnitViewModel vm, MUnitWord item, int phraseid) { item.CopyProperties(ItemEdit); vmSingleWord = new SingleWordViewModel(item.WORD, vm.vmSettings); ItemEdit.Save = ReactiveCommand.CreateFromTask(async() => { ItemEdit.CopyProperties(item); item.WORD = vm.vmSettings.AutoCorrectInput(item.WORD); if (item.ID != 0) { await vm.Update(item); } else { await vm.Create(item); if (phraseid != 0) { await wordPhraseDS.Associate(item.WORDID, phraseid); } } }, ItemEdit.IsValid()); }