コード例 #1
0
ファイル: SKUCollections.cs プロジェクト: ohel/kerppi
        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;
        }
コード例 #2
0
ファイル: SKUCollections.cs プロジェクト: ohel/kerppi
        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;
        }