Пример #1
0
        public void UpdateGraph(ProductLine productLine)
        {
            if (productLine == null)
            {
                throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null.");
            }

            productLine.ApplyKeys();

            Update(productLine);
            MergeAll(productLine.Products);
        }
Пример #2
0
        public int Create(ProductLine productLine)
        {
            if (productLine == null)
            {
                throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null.");
            }

            var key = Insert <ProductLine, int>(productLine);

            productLine.ApplyKeys();
            InsertAll(productLine.Products);
            return(key);
        }
Пример #3
0
        public void UpdateGraphWithDeletes(ProductLine productLine, IList <int> productKeysToRemove)
        {
            if (productLine == null)
            {
                throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null.");
            }

            productLine.ApplyKeys();

            Update(productLine);

            if (productKeysToRemove?.Any() == true)
            {
                Delete <Product>(e => productKeysToRemove.Contains(e.ProductKey));
            }

            if (productLine.Products?.Any() == true)
            {
                MergeAll <Product>(productLine.Products);
            }
        }
Пример #4
0
        public void UpdateGraphWithChildDeletes(ProductLine productLine)
        {
            if (productLine == null)
            {
                throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null.");
            }

            productLine.ApplyKeys();

            var products            = Query <Product>(p => p.ProductLineKey == productLine.ProductLineKey);
            var originalProductKeys = products
                                      .Select(p => p.ProductKey);
            var currentProductKeys = productLine
                                     .Products
                                     .Select(e => e.ProductKey);
            var productKeysToRemove = originalProductKeys
                                      .Except(currentProductKeys)
                                      .AsList();

            UpdateGraphWithDeletes(productLine, productKeysToRemove);
        }