public List <ConfigurationModel> CalculatePalletConfiguration(PalletModel palletModel)
        {
            var output = new List <ConfigurationModel>();

            foreach (var option in StackingOptionModel.GenerateListOfStackingOptions())
            {
                output.Add(CalculateOption(palletModel, option));
            }

            return(output);
        }
        public ConfigurationModel CalculateOption(PalletModel palletModel, StackingOptionModel stackingOption)
        {
            // PalletModel validation
            IsModelValid(palletModel);

            var output = new ConfigurationModel();

            // GetBoxSize
            output.BoxSize = GetBoxSize(palletModel);
            // GetPalletSize
            output.PalletSize = GetPalletSize(palletModel);
            // Option Name
            output.OptionName = stackingOption.Name;
            // Calculate max possible rows and collumns
            var maxRows    = output.PalletSize.X / palletModel.BoxSizeX;
            var maxColumns = output.PalletSize.Z / palletModel.BoxSizeZ;
            // Calculate Standard Layer
            var standardPalletZ = CalculateStandardPalletZ(stackingOption.Rotation, maxColumns, palletModel.BoxSizeZ, stackingOption.Mode);

            output.Standard = CalculateLayer(output.PalletSize.X, palletModel.BoxSizeX, standardPalletZ, palletModel.BoxSizeZ);
            // Calculate Rotated Layer
            var rotatedPalletZ = output.PalletSize.Z - standardPalletZ;

            output.Rotated = CalculateLayer(output.PalletSize.X, palletModel.BoxSizeZ, rotatedPalletZ, palletModel.BoxSizeX);
            // Calculate boxes per layer
            int boxesPerLayer = (output.Standard.RowsPerLayer * output.Standard.ColumnsPerLayer)
                                + (output.Rotated.RowsPerLayer * output.Rotated.ColumnsPerLayer);

            // Calculate Layers Quantity
            output.LayersQuantity = CalculateLayersQuantity(palletModel, output.PalletSize.Y, boxesPerLayer);
            // Calculate total number of boxes
            int maxVolume, boxVolume;

            output.NumberOfBoxes = CalculateNumberOfBoxes(palletModel, output, boxesPerLayer, out maxVolume, out boxVolume);
            int actualVolume = output.NumberOfBoxes * boxVolume;

            // Calculate Volume
            output.Volume = Convert.ToDouble(actualVolume) / Convert.ToDouble(maxVolume);
            // Calculate total Weight and Height
            output.TotalHeight = output.PalletSize.Y + (palletModel.BoxSizeY * output.LayersQuantity);
            output.TotalWeight = output.NumberOfBoxes * palletModel.BoxWeight;

            return(output);
        }