private void ImportMonsters()
 {
     foreach (MonsterModel monsterModel in _monsters)
     {
         if (_addAllEntries)
         {
             _compendium.AddMonster(monsterModel);
         }
         else if (_skipDuplicateEntries)
         {
             if (!_compendium.Monsters.Any(x => x.Name.Equals(monsterModel.Name, StringComparison.CurrentCultureIgnoreCase)))
             {
                 _compendium.AddMonster(monsterModel);
             }
         }
         else if (_replaceExistingEntries)
         {
             MonsterModel existing = _compendium.Monsters.FirstOrDefault(x => x.Name.Equals(monsterModel.Name, StringComparison.CurrentCultureIgnoreCase));
             if (existing == null)
             {
                 _compendium.AddMonster(monsterModel);
             }
             else
             {
                 monsterModel.Id = existing.Id;
                 _compendium.UpdateMonster(monsterModel);
             }
         }
     }
 }
        private void Add()
        {
            bool addMonster = true;

            if (_editMonsterXML != null)
            {
                if (_editHasUnsavedChanges)
                {
                    string body = String.Format("{0} has unsaved changes.{1}What would you like to do?",
                                                _selectedMonster.Name, Environment.NewLine + Environment.NewLine);
                    string accept = "Save and Continue";
                    string reject = "Discard Changes";
                    string cancel = "Cancel Navigation";
                    bool?  result = _dialogService.ShowConfirmationDialog("Unsaved Changes", body, accept, reject, cancel);

                    if (result == true)
                    {
                        if (!SaveEditMonster())
                        {
                            addMonster = false;
                        }
                    }
                    else if (result == false)
                    {
                        CancelEditMonster();
                    }
                    else
                    {
                        addMonster = false;
                    }
                }
                else
                {
                    CancelEditMonster();
                }
            }

            if (addMonster)
            {
                string xml = @"<name>New Monster</name>
									<size></size>
									<type></type>
									<alignment></alignment>
									<ac></ac>
									<hp></hp>
									<speed></speed>
									<str></str>
									<dex></dex>
									<con></con>
									<int></int>
									<wis></wis>
									<cha></cha>
									<save></save>
									<skill></skill>
									<resist></resist>
									<vulnerable></vulnerable>
									<immune></immune>
									<conditionImmune></conditionImmune>
									<senses></senses>
									<passive></passive>
									<languages></languages>
									<cr></cr>
									<trait>
										 <name></name>
										 <text></text>
									</trait>
									<action>
										 <name></name>
										 <text></text>
										 <attack></attack>
									</action>
									<legendary>
										 <name></name>
										 <text></text>
									</legendary>
									<spells></spells>
									<slots></slots>
									<environment></environment>"                                    ;

                MonsterModel monsterModel = _xmlImporter.GetMonster(xml);

                _compendium.AddMonster(monsterModel);

                if (_monsterSearchService.SearchInputApplies(_monsterSearchInput, monsterModel))
                {
                    MonsterListItemViewModel listItem = new MonsterListItemViewModel(monsterModel, _stringService);
                    _monsters.Add(listItem);
                    foreach (MonsterListItemViewModel item in _monsters)
                    {
                        item.IsSelected = false;
                    }
                    listItem.IsSelected = true;
                }

                _selectedMonster = new MonsterViewModel(monsterModel);

                _editMonsterXML = monsterModel.XML;

                SortMonsters();

                _compendium.SaveMonsters();

                OnPropertyChanged(nameof(EditingMonsterXML));
                OnPropertyChanged(nameof(IsEditingMonster));
                OnPropertyChanged(nameof(SelectedMonster));
            }
        }