public SKUCollections() { if (!DesignerProperties.GetIsInDesignMode(new DependencyObject())) { CurrentSKUCollection = new DataModel.SKUCollection(); Refresh(); } }
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { var skuCollection = new DataModel.SKUCollection(); if (e.AddedItems.Count > 0) { skuCollection = e.AddedItems[0] as DataModel.SKUCollection ?? skuCollection; } ((ViewModels.SKUCollections)DataContext).CurrentSKUCollection = skuCollection.Copy(); }
public void SaveCurrentSKUCollection() { DataModel.SKUCollection match = SKUHandlerInstance.SKUCollectionList.FirstOrDefault(c => c.Code == CurrentSKUCollection.Code); // The user is (visually) updating based on SKUCollection code, not database id. CurrentSKUCollection.Id = match == null ? null : match.Id; bool noNewLinks = (CurrentSKUCollection != null && match != null) && (CurrentSKUCollection.SKUs.Count == match.SKUs.Count) && (CurrentSKUCollection.SKUs.Zip(match.SKUs, (a, b) => a.Id == b.Id).All(boolVal => boolVal)); CurrentSKUCollection.Save(noNewLinks); SKUHandlerInstance.SKUCollectionList = new ObservableCollection <DataModel.SKUCollection>(DataModel.SKUCollection.LoadAll()); }
public void RemoveSKUCollection(DataModel.SKUCollection SKUCollection) { SKUCollection.Delete(); SKUHandlerInstance.SKUCollectionList.Remove(SKUCollection); }