Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }