public void AddProduct(ProductBiz product) { foreach (var item in TryingOnProducts) { if (item.Id == product.Id) { return; } } TryingOnProducts.Add(product); if (tryingOnProductsAdded != null) { tryingOnProductsAdded(product); } }
public void AddProducts(List <ProductBiz> products) { if (products == null) { return; } List <ProductBiz> vildProducts = new List <ProductBiz>(); foreach (var product in products) { ProductBiz hasProduct = TryingOnProducts.SingleOrDefault(p => p.Id == product.Id); if (hasProduct == null) { vildProducts.Add(product); TryingOnProducts.Add(product); } } if (tryingOnMutiProductsAdded != null) { tryingOnMutiProductsAdded(vildProducts); } }
public void RemoveProduct(string Id) { int selIndex = 0; foreach (var item in TryingOnProducts) { if (item.Id == Id) { TryingOnProducts.Remove(item); break; } selIndex++; } //当前删除的也是被选择的 if (currentIndex == selIndex) { if (TryingOnProducts.Count > selIndex) { currentIndex = selIndex; } else { currentIndex = selIndex - 1; } } else { if (selIndex < currentIndex) { currentIndex = currentIndex - 1; } } if (tryingOnProductsRemoved != null) { tryingOnProductsRemoved(); } }