public static MoveBetweenInventoriesInputData Optimize(MoveBetweenInventoriesInputData first, MoveBetweenInventoriesInputData second)
        {
            // check
            if (first.IdEntity != second.IdEntity)
            {
                throw new Exception();
            }

            if (!(first.InputDatesCanSum(second)))
            {
                throw new NotSupportedException("Different Inventories!");
            }

            if (first.FromInventory == second.FromInventory)
            {
                var sum       = first.Amount + second.Amount;
                var inputData = new MoveBetweenInventoriesInputData(first.FromInventory, first.ToInventory, first.IdEntity, sum);
                return(inputData);
            }
            else
            {
                var sum = first.Amount - second.Amount;
                if (sum == 0)
                {
                    return(null);
                }

                if (sum > 0)
                {
                    var inputData = new MoveBetweenInventoriesInputData(first.FromInventory, first.ToInventory, first.IdEntity, sum);
                    return(inputData);
                }
                else
                {
                    var inputData = new MoveBetweenInventoriesInputData(second.FromInventory, second.ToInventory, first.IdEntity, -sum);
                    return(inputData);
                }
            }
        }
 public static bool InputDatesCanSum(this MoveBetweenInventoriesInputData first, MoveBetweenInventoriesInputData second)
 {
     return(!(first.Inventories.Concat(second.Inventories).Distinct().Count() > 2));
 }