private void Products_CurrentItemChanged(ProductNotifyGeneric oldProduct, ProductNotifyGeneric newProduct)
 {
     if (newProduct != null)
     {
         newProduct.PropertyChanged += Product_PropertyChanged;
     }
     if (oldProduct != null)
     {
         oldProduct.PropertyChanged -= Product_PropertyChanged;
     }
 }
        private void ValidateUniqueName(ProductNotifyGeneric product)
        {
            string errorMessage = "The product name must be unique.";

            if (!IsProductNameUnique(product))
            {
                product.ExternalErrors.Add(errorMessage);
            }
            else
            {
                product.ExternalErrors.Remove(errorMessage);
            }
        }
 private bool IsProductNameUnique(ProductNotifyGeneric product) => Products.Count(p => p.Id != product.Id && p.Name != string.Empty && p.Name == product.Name) == 0;