Beispiel #1
0
        private bool SaveEditCondition()
        {
            bool saved = false;

            try
            {
                ConditionModel model = _xmlImporter.GetCondition(_editConditionXML);

                if (model != null)
                {
                    model.Id = _selectedCondition.ConditionModel.Id;
                    _compendium.UpdateCondition(model);
                    _selectedCondition = new ConditionViewModel(model);

                    ConditionListItemViewModel oldListItem = _conditions.FirstOrDefault(x => x.ConditionModel.Id == model.Id);
                    if (oldListItem != null)
                    {
                        if (_conditionSearchService.SearchInputApplies(_conditionSearchInput, model))
                        {
                            oldListItem.UpdateModel(model);
                        }
                        else
                        {
                            _conditions.Remove(oldListItem);
                        }
                    }

                    _editConditionXML      = null;
                    _editHasUnsavedChanges = false;

                    SortConditions();

                    _compendium.SaveConditions();

                    OnPropertyChanged(nameof(SelectedCondition));
                    OnPropertyChanged(nameof(EditingConditionXML));
                    OnPropertyChanged(nameof(IsEditingCondition));
                    OnPropertyChanged(nameof(HasUnsavedChanges));

                    saved = true;
                }
                else
                {
                    string message = String.Format("Something went wrong...{0}{1}{2}{3}",
                                                   Environment.NewLine + Environment.NewLine,
                                                   "The following are required:",
                                                   Environment.NewLine,
                                                   "-name");
                    _dialogService.ShowConfirmationDialog("Unable To Save", message, "OK", null, null);
                }
            }
            catch (Exception ex)
            {
                string message = String.Format("Something went wrong...{0}{1}",
                                               Environment.NewLine + Environment.NewLine,
                                               ex.Message);
                _dialogService.ShowConfirmationDialog("Unable To Save", message, "OK", null, null);
            }

            return(saved);
        }