private void UpdateDatabaseSupplier(NotificationMessage<Supplier> msg) { _selectedDevice = null; var changedSupplier = msg.Content; switch (msg.Notification) { case ("AddSupplier"): _context.Suppliers.Load(); _suppliers = _context.Suppliers.GetLocal(); RaisePropertyChanged("Suppliers"); //RaisePropertyChanged("SupplierCollectionView"); break; case ("ModifySupplier"): _context.Devices.UpdateSupplierNames(changedSupplier); _context.Complete(); _context.Devices.Load(); _context.Suppliers.Load(); RaisePropertyChanged("Devices"); RaisePropertyChanged("Suppliers"); break; case ("DeleteSupplier"): // The delete is restricted from database if any device still points to the category //_context.Complete(); //TODO: make sure only unlinked catgories can be deleted _context.Devices.Load(); _context.Suppliers.Load(); //_devices = _context.Devices.GetLocal(); //_suppliers.Remove(changedSupplier); _suppliers = _context.Suppliers.GetLocal(); RaisePropertyChanged("Suppliers"); RaisePropertyChanged("Devices"); //DeviceCollectionView = CollectionViewSource.GetDefaultView(_devices); //RaisePropertyChanged("DeviceCollectionView"); //SupplierCollectionView = (CollectionView) new CollectionViewSource {Source = _suppliers}.View; //RaisePropertyChanged("SupplierCollectionView"); break; default: break; } }
private void UpdateDatabaseCategory(NotificationMessage<Category> msg) { _selectedDevice = null; var category = msg.Content; switch (msg.Notification) { case ("AddCategory"): _context.Categories.Load(); _categories = _context.Categories.GetLocal(); RaisePropertyChanged("Categories"); //CategoryCollectionView = (CollectionView) new CollectionViewSource {Source = _categories}.View; //RaisePropertyChanged("CategoryCollectionView"); break; case ("ModifyCategory"): _context.Devices.UpdateCategoryNames(category); _context.Complete(); _context.Devices.Load(); _context.Categories.Load(); _devices = _context.Devices.GetLocal(); _categories = _context.Categories.GetLocal(); RaisePropertyChanged("Devices"); RaisePropertyChanged("Categories"); //DeviceCollectionView = CollectionViewSource.GetDefaultView(_devices); //RaisePropertyChanged("DeviceCollectionView"); //CategoryCollectionView = (CollectionView) new CollectionViewSource {Source = _categories}.View; //RaisePropertyChanged("CategoryCollectionView"); break; case ("DeleteCategory"): // The delete is restricted from database if any device still points to the category //_context.Devices.UpdateCategoriesDeleted(); _context.Complete(); //TODO: make sure only unlinked catgories can be deleted _context.Devices.Load(); _context.Categories.Load(); //_devices = _context.Devices.GetLocal(); _categories = _context.Categories.GetLocal(); RaisePropertyChanged("Categories"); RaisePropertyChanged("Devices"); //DeviceCollectionView = CollectionViewSource.GetDefaultView(_devices); //RaisePropertyChanged("DeviceCollectionView"); //CategoryCollectionView = (CollectionView) new CollectionViewSource {Source = _categories}.View; //RaisePropertyChanged("CategoryCollectionView"); break; default: break; } }
private void Device_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { var device = new Device(); switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (var item in e.NewItems) { var entity = item as Device; if (entity != null && !_isAddedbyApp) { //Adding to the database is working by itself! } } _context.Complete(); break; case NotifyCollectionChangedAction.Reset: var count = _context.Complete(); break; } }
private void AddNewSocketToDevice(Device selectedDevice, Socket socket) { _context.Sockets.CreateNewLinkedSocket(selectedDevice, socket); _context.Complete(); }
private void UpdateDatabaseProductType(NotificationMessage<ProductType> msg) { _selectedDevice = null; var productTypes = msg.Content; switch (msg.Notification) { case ("AddProductType"): _context.ProductTypes.Load(); _productTypes = _context.ProductTypes.GetLocal(); RaisePropertyChanged("ProductTypes"); //ProductTypeCollectionView = (CollectionView) new CollectionViewSource {Source = _productTypes}.View; //RaisePropertyChanged("ProductTypeCollectionView"); break; case ("ModifyProductType"): _context.Devices.UpdateProductTypeNames(productTypes); _context.Complete(); _context.Devices.Load(); _context.SignalTypes.Load(); _devices = _context.Devices.GetLocal(); _productTypes = _context.ProductTypes.GetLocal(); RaisePropertyChanged("ProductTypes"); RaisePropertyChanged("Devices"); /* DeviceCollectionView = CollectionViewSource.GetDefaultView(_devices); RaisePropertyChanged("DeviceCollectionView"); ProductTypeCollectionView = (CollectionView) new CollectionViewSource {Source = _productTypes}.View; RaisePropertyChanged("ProductTypeCollectionView");*/ break; case ("DeleteProductType"): // The delete is restricted from database if any device still points to the cable type _context.Complete(); //TODO: make sure only unlinked catgories can be deleted _context.Devices.Load(); _context.ProductTypes.Load(); RaisePropertyChanged("Devices"); //_devices = _context.Devices.GetLocal(); _productTypes = _context.ProductTypes.GetLocal(); RaisePropertyChanged("ProductTypes"); /* DeviceCollectionView = CollectionViewSource.GetDefaultView(_devices); RaisePropertyChanged("DeviceCollectionView"); ProductTypeCollectionView = (CollectionView) new CollectionViewSource {Source = _productTypes}.View; RaisePropertyChanged("ProductTypeCollectionView");*/ break; default: break; } }