public WareGroupTreeViewWrapper(WareGroup wareGroup, Action<WareGroupTreeViewWrapper> onEdit, Action<WareGroupTreeViewWrapper> onSelect, WareGroupTreeViewWrapper parent) { _wareGroup = wareGroup; _parent = parent; OnEdit = onEdit; OnSelect = onSelect; _children = new ObservableCollection<WareGroupTreeViewWrapper>( (from child in _wareGroup.Children select new WareGroupTreeViewWrapper(child, onEdit, onSelect, this)) ); }
public void CanAddNewClient() { var client = new WareGroup { Name = "child new", Parent = _child1_1 }; _repository.Save(client); using (ISession session = sessions.OpenSession()) { var fromDb = session.Get<WareGroup>(client.Id); Assert.IsNotNull(fromDb); Assert.AreEqual(client, fromDb); Assert.AreEqual(client.Parent.Name, fromDb.Parent.Name); } }
private void CreateInitialData() { _root = new WareGroup {Name = "Электронные товары"}; _child1 = new WareGroup {Name = "Мобильные телефоны"}; _child1_1 = new WareGroup {Name = "Раскладушки"}; _child1_2 = new WareGroup {Name = "Моноблоки"}; _child2 = new WareGroup {Name = "Процессоры"}; _root.AddChild(_child1); _root.AddChild(_child2); _child1.AddChild(_child1_1); _child1.AddChild(_child1_2); _root2 = new WareGroup{Name = "Антиквариат"}; _producer = new Producer {Caption = "Nokia"}; _producer2 = new Producer {Caption = "Intel"}; _model1 = new WareType {Name = "N78", WareGroup = _child1_2,Producer = _producer}; _model2 = new WareType { Name = "T2100", WareGroup = _child2,Producer = _producer2}; using (var session = sessions.OpenSession()) { using (var transaction = session.BeginTransaction()) { session.Save(_root); session.Save(_child1); session.Save(_child1_1); session.Save(_child1); session.Save(_child1_2); session.Save(_child2); session.Save(_root2); transaction.Commit(); } using (var transaction = session.BeginTransaction()) { session.Save(_root2); transaction.Commit(); } using (var transaction = session.BeginTransaction()) { session.Save(_producer); session.Save(_producer2); transaction.Commit(); } using (ITransaction transaction = session.BeginTransaction()) { session.Save(_model1); transaction.Commit(); } using (ITransaction transaction = session.BeginTransaction()) { session.Save(_model2); transaction.Commit(); } } _repository = new Dao<WareType>(sessions); var repositorysession = sessions.OpenSession(); CurrentSessionContext.Bind(repositorysession); }
private void CreateInitialData() { _wareGroup = new WareGroup {Name = "Мобильный телефон"}; _producer = new Producer {Caption = "LG"}; _wareType = new WareType {Name = "i234", Producer = _producer, WareGroup = _wareGroup}; _wareType2 = new WareType {Name = "4324", Producer = _producer, WareGroup = _wareGroup}; _client = new Client {FIO = "Розничный клиент",ContactPhone = "нет",Identification = "нет"}; _client2 = new Client{FIO ="Барыга Леха",ContactPhone = "78-32-43",Identification = "Талон"}; _worker = new Worker{FIO = "Саша"}; _worker2 = new Worker {FIO = "Вова"}; _ware = new Ware { WareType = _wareType, ClientBrought = _client, Description = "Потертый телефон", Worker = _worker }; _ware2 = new Ware { ClientBrought = _client2, Description = "Нет крышки", WareType = _wareType2, Worker = _worker2 }; using (ISession session = sessions.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { session.Save(_wareGroup); session.Save(_producer); session.Save(_wareType); session.Save(_wareType2); session.Save(_client); session.Save(_client2); session.Save(_worker); session.Save(_producer); session.Save(_producer); session.Save(_worker2); session.Save(_ware); session.Save(_ware2); transaction.Commit(); } _repository = new Dao<Ware>(sessions); var repositorysession = sessions.OpenSession(); CurrentSessionContext.Bind(repositorysession); }
private void CreateInitialData() { _root = new WareGroup{ Name = "root" }; _child1 = new WareGroup { Name = "child1" }; _child2 = new WareGroup { Name = "child2" }; _child1_1 = new WareGroup { Name = "grand child 1-1" }; _child1_2 = new WareGroup { Name = "grand child 1-2" }; _child1_3 = new WareGroup { Name = "grand child 1-3" }; _child2_1 = new WareGroup { Name = "grand child 2-1" }; _child2_2 = new WareGroup { Name = "grand child 2-2" }; _root.AddChild(_child1); _root.AddChild(_child2); _child1.AddChild(_child1_1); _child1.AddChild(_child1_2); _child1.AddChild(_child1_3); _child2.AddChild(_child2_1); _child2.AddChild(_child2_2); using (var session = sessions.OpenSession()) using (var transaction = session.BeginTransaction()) { session.Save(_root); session.Save(_child1); session.Save(_child2); session.Save(_child1_1); session.Save(_child1_2); session.Save(_child1_3); session.Save(_child2_1); session.Save(_child2_2); transaction.Commit(); } _repository = new Dao<WareGroup>(sessions); var repositorysession = sessions.OpenSession(); CurrentSessionContext.Bind(repositorysession); }
public WareGroupTreeViewWrapper(WareGroup wareGroup, Action<WareGroupTreeViewWrapper> onEdit, Action<WareGroupTreeViewWrapper> onSelect) : this(wareGroup, onEdit, onSelect, null) { }
public virtual void RemoveChild(WareGroup children) { children.Parent = null; Children.Remove(children); }
public virtual void AddChild(WareGroup children) { children.Parent = this; Children.Add(children); }