public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var importedManure = _mapper.Map <ImportedManure>(request);

                if (importedManure.ManureType == ManureMaterialType.Solid)
                {
                    importedManure.AnnualAmountCubicMetersVolume =
                        _manureUnitConversionCalculator.GetCubicMetersVolume(importedManure.ManureType,
                                                                             importedManure.Moisture.Value,
                                                                             importedManure.AnnualAmount,
                                                                             importedManure.Units);

                    importedManure.AnnualAmountCubicYardsVolume =
                        _manureUnitConversionCalculator.GetCubicYardsVolume(importedManure.ManureType,
                                                                            importedManure.Moisture.Value,
                                                                            importedManure.AnnualAmount,
                                                                            importedManure.Units);

                    importedManure.AnnualAmountTonsWeight =
                        _manureUnitConversionCalculator.GetTonsWeight(importedManure.ManureType,
                                                                      importedManure.Moisture.Value,
                                                                      importedManure.AnnualAmount,
                                                                      importedManure.Units);
                }
                else
                {
                    importedManure.AnnualAmountUSGallonsVolume =
                        _manureUnitConversionCalculator.GetUSGallonsVolume(importedManure.ManureType,
                                                                           importedManure.AnnualAmount,
                                                                           importedManure.Units);
                }

                if (!importedManure.Id.HasValue)
                {
                    _ud.AddImportedManure(importedManure);
                    request.ManureImportId = importedManure.Id;
                }
                else
                {
                    _ud.UpdateImportedManure(importedManure);
                }

                return(await Task.FromResult(new Unit()));
            }
Ejemplo n.º 2
0
        public SeparatedManure CalculateSeparatedManure(decimal liquidVolumeToSeparateGallons, int wholePercentLiquidSeparated)
        {
            var solidsSeparatedUSGallons = Convert.ToInt32(liquidVolumeToSeparateGallons * (wholePercentLiquidSeparated / 100M));
            var separatedManure          = new SeparatedManure
            {
                LiquidUSGallons = liquidVolumeToSeparateGallons - solidsSeparatedUSGallons
            };

            //var amountToConvert = (100 - wholePercentLiquidSeparated) / 100M * liquidVolumeToSeparateGallons;
            var moistureWholePercent = 70;

            //Divide by Factor of 1 Gallon to Cubic Meter
            var solidsSeperatedCubicMeters = solidsSeparatedUSGallons / _manureUnitConversionCalculator.GetUSGallonsVolume(ManureMaterialType.Liquid,
                                                                                                                           1M,
                                                                                                                           AnnualAmountUnits.CubicMeters);

            separatedManure.SolidTons = Convert.ToInt32(_manureUnitConversionCalculator.GetTonsWeight(ManureMaterialType.Solid,
                                                                                                      moistureWholePercent,
                                                                                                      Convert.ToDecimal(solidsSeperatedCubicMeters),
                                                                                                      AnnualAmountUnits.CubicMeters));

            return(separatedManure);
        }