public WasteRecoveryViewModel(NotificationApplication notification,
                                      WasteRecovery wasteRecovery,
                                      WasteDisposal wasteDisposal,
                                      WasteRecoveryFormatter wasteRecoveryFormatter)
        {
            if (notification == null)
            {
                return;
            }

            if (notification.WasteRecoveryInformationProvidedByImporter.GetValueOrDefault())
            {
                annexMessage = string.Empty;
                return;
            }

            if (wasteDisposal != null)
            {
                methodOfDisposal = wasteDisposal.Method ?? string.Empty;
            }

            if (wasteRecovery != null && wasteRecovery.PercentageRecoverable != null)
            {
                percentageRecoverable    = wasteRecoveryFormatter.NullableDecimalAsPercentage(wasteRecovery.PercentageRecoverable.Value);
                percentageNonRecoverable =
                    wasteRecoveryFormatter.NullableDecimalAsPercentage(100 - wasteRecovery.PercentageRecoverable.Value);
            }

            estimatedAmountText = wasteRecoveryFormatter
                                  .CostAmountWithUnits(wasteRecovery,
                                                       ri => ri.EstimatedValue);

            costAmountText = wasteRecoveryFormatter
                             .CostAmountWithUnits(wasteRecovery,
                                                  ri => ri.RecoveryCost);

            disposalAmountText = wasteRecoveryFormatter
                                 .CostAmountWithUnits(wasteDisposal,
                                                      ri => ri.Cost);

            annexMessage = string.Empty;
        }
        public WasteRecoveryViewModel(NotificationApplication notification,
            WasteRecovery wasteRecovery,
            WasteDisposal wasteDisposal,
            WasteRecoveryFormatter wasteRecoveryFormatter)
        {
            if (notification == null)
            {
                return;
            }

            if (notification.WasteRecoveryInformationProvidedByImporter.GetValueOrDefault())
            {
                annexMessage = string.Empty;
                return;
            }

            if (wasteDisposal != null)
            {
                methodOfDisposal = wasteDisposal.Method ?? string.Empty;
            }
            
            if (wasteRecovery != null && wasteRecovery.PercentageRecoverable != null)
            {
                percentageRecoverable = wasteRecoveryFormatter.NullableDecimalAsPercentage(wasteRecovery.PercentageRecoverable.Value);
                percentageNonRecoverable =
                    wasteRecoveryFormatter.NullableDecimalAsPercentage(100 - wasteRecovery.PercentageRecoverable.Value);
            }

            estimatedAmountText = wasteRecoveryFormatter
                .CostAmountWithUnits(wasteRecovery, 
                    ri => ri.EstimatedValue);

            costAmountText = wasteRecoveryFormatter
                .CostAmountWithUnits(wasteRecovery,
                    ri => ri.RecoveryCost);

            disposalAmountText = wasteRecoveryFormatter
                .CostAmountWithUnits(wasteDisposal,
                    ri => ri.Cost);

            annexMessage = string.Empty;
        }
Beispiel #3
0
        public void NullableDecimalAsPercentage_NoDecimalPlaces_ReturnsCorrectString()
        {
            var result = formatter.NullableDecimalAsPercentage(97m);

            Assert.Equal("97%", result);
        }