public RenameWindow(Category category) : this() { _renameType = RenameType.RenameCategory; Title = "Переименовать категорию"; ResultNewName = category.Name; NewName.Text = category.Name; }
/// <summary> /// Загрузить категории /// </summary> /// <returns></returns> public CategoryList LoadCategories() { var list = new CategoryList(); if (server == null) return null; try { using (var documentStore = server.OpenClient()) { var categories = documentStore.Query<Category>(); //foreach (Category category in categories) // documentStore.Delete(category); //documentStore.Commit(); if (categories.Count() > 0) { foreach (var category in categories) if (category!=null) list.Add(category); } else { var c = new Category { Name = "Default" }; list.Add(c); documentStore.Store(c); documentStore.Commit(); } foreach (var category in list) category.SetOwner(list); list.Reorder(); } } catch (Exception ex) { MessageBox.Show("Ошибка выборки категорий из БД." + ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } return list; }