public PhrasesUnitBatchAddViewModel(PhrasesUnitViewModel vm)
        {
            var item = vm.NewUnitPhrase();

            item.CopyProperties(ItemEdit);
            ItemEdit.Save = ReactiveCommand.CreateFromTask(async() =>
            {
                ItemEdit.CopyProperties(item);
                var phrases = ItemEdit.PHRASES.Split('\n').Select(s => s.Trim()).ToList();
                for (int i = 0; i < phrases.Count; i += 2)
                {
                    item.PHRASE      = vm.vmSettings.AutoCorrectInput(phrases[i]);
                    item.TRANSLATION = phrases[i + 1];
                    await vm.Create(item);
                    item.SEQNUM++;
                }
            });
        }
Ejemplo n.º 2
0
 public PhrasesUnitDetailViewModel(PhrasesUnitViewModel vm, MUnitPhrase item, int wordid)
 {
     item.CopyProperties(ItemEdit);
     vmSinglePhrase = new SinglePhraseViewModel(item.PHRASE, vm.vmSettings);
     ItemEdit.Save  = ReactiveCommand.CreateFromTask(async() =>
     {
         ItemEdit.CopyProperties(item);
         item.PHRASE = vm.vmSettings.AutoCorrectInput(item.PHRASE);
         if (item.ID != 0)
         {
             await vm.Update(item);
         }
         else
         {
             await vm.Create(item);
             if (wordid != 0)
             {
                 await wordPhraseDS.Associate(wordid, item.PHRASEID);
             }
         }
     }, ItemEdit.IsValid());
 }