private IEnumerable <IWordTreeViewItem> CreateItemsFromXml(XmlNode rootNode, IWordTreeViewItem rootNodeItem)
        {
            var result = new IWordTreeViewItem[rootNode.ChildNodes.Count];

            for (int i = 0; i < rootNode.ChildNodes.Count; i++)
            {
                XmlNode node = rootNode.ChildNodes[i];
                switch (node.Name)
                {
                case WordNode:
                    result[i] = new WordViewModel(node.Attributes[TextAttribute].Value, rootNodeItem, _viewModel.DataService);
                    break;

                case CategoryNode:
                    var newNode  = new WordCategoryViewModel(node.Attributes[TextAttribute].Value, rootNodeItem, _viewModel.DataService);
                    var children = CreateItemsFromXml(node, newNode);

                    newNode.Children = new System.Collections.ObjectModel.ObservableCollection <IWordTreeViewItem>(children);
                    result[i]        = newNode;
                    break;

                default:
                    throw new XmlException($"unknown node name {node.Name}");
                }
            }

            return(result);
        }
        public ActionResult Create()
        {
            var viewModel = new WordCategoryViewModel();

            viewModel.Word           = new Word();
            viewModel.WordCategories = wordCategoriesContext.Collection();

            return(View(viewModel));
        }
        public ActionResult Edit(string Id)
        {
            Word word = wordContext.Find(Id);

            if (word == null)
            {
                return(HttpNotFound());
            }
            else
            {
                var viewModel = new WordCategoryViewModel();
                viewModel.Word           = word;
                viewModel.WordCategories = wordCategoriesContext.Collection();
                return(View(viewModel));
            }
        }