public void RemoveFromCurrentSKUCollection(DataModel.SKU sku) { var newSKUCollection = CurrentSKUCollection.Copy(); int matchIndex = newSKUCollection.SKUs.FindIndex(s => s.Id == sku.Id); newSKUCollection.SKUs.RemoveAt(newSKUCollection.SKUs.FindIndex(s => s.Id == sku.Id)); CurrentSKUCollection = newSKUCollection; }
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 AddToCurrentSKUCollection(List <DataModel.SKU> skus) { skus.AddRange(CurrentSKUCollection.SKUs); var skusNew = new List <DataModel.SKU>(); foreach (var sku in skus) { if (skusNew.FirstOrDefault(f => f.Id == sku.Id) == null) { skusNew.Add(sku); } } var newSKUCollection = CurrentSKUCollection.Copy(); newSKUCollection.SKUs = skusNew; CurrentSKUCollection = newSKUCollection; }