Beispiel #1
0
        public async Task <bool> HandleAsync(SaveWasteRecovery message)
        {
            var wasteRecovery = await repository.GetByNotificationId(message.NotificationId);

            var newPercentage     = new Percentage(message.PercentageRecoverable);
            var newEstimatedValue = new EstimatedValue(message.EstimatedValue.Unit, message.EstimatedValue.Amount);
            var newRecoveryCost   = new RecoveryCost(message.RecoveryCost.Unit, message.RecoveryCost.Amount);

            if (wasteRecovery == null)
            {
                wasteRecovery = new WasteRecovery(
                    message.NotificationId,
                    newPercentage,
                    newEstimatedValue,
                    newRecoveryCost);

                context.WasteRecoveries.Add(wasteRecovery);
            }
            else
            {
                wasteRecovery.Update(newPercentage, newEstimatedValue, newRecoveryCost);
            }

            await context.SaveChangesAsync();

            return(true);
        }
        public void CanAddWasteRecoveryValues()
        {
            var estimatedValue = new EstimatedValue(ValuePerWeightUnits.Kilogram, 10);
            var recoveryCost   = new RecoveryCost(ValuePerWeightUnits.Tonne, 50);

            var wasteRecovery = new WasteRecovery(Guid.NewGuid(), new Percentage(50), estimatedValue, recoveryCost);

            Assert.NotNull(wasteRecovery);
        }
        public void CanAddWasteRecoveryValues()
        {
            var estimatedValue = new EstimatedValue(ValuePerWeightUnits.Kilogram, 10);
            var recoveryCost = new RecoveryCost(ValuePerWeightUnits.Tonne, 50);

            var wasteRecovery = new WasteRecovery(Guid.NewGuid(), new Percentage(50), estimatedValue, recoveryCost);

            Assert.NotNull(wasteRecovery);
        }
Beispiel #4
0
        public void Update(Percentage percentageRecoverable,
                           EstimatedValue estimatedValue,
                           RecoveryCost recoveryCost)
        {
            PercentageRecoverable = percentageRecoverable;
            EstimatedValue        = estimatedValue;
            RecoveryCost          = recoveryCost;

            RaiseEvent(new PercentageChangedEvent(this.NotificationId, percentageRecoverable));
        }
Beispiel #5
0
 public WasteRecovery(Guid notificationId,
                      Percentage percentageRecoverable,
                      EstimatedValue estimatedValue,
                      RecoveryCost recoveryCost)
 {
     NotificationId        = notificationId;
     PercentageRecoverable = percentageRecoverable;
     EstimatedValue        = estimatedValue;
     RecoveryCost          = recoveryCost;
 }
        public void Update(Percentage percentageRecoverable,
            EstimatedValue estimatedValue,
            RecoveryCost recoveryCost)
        {
            PercentageRecoverable = percentageRecoverable;
            EstimatedValue = estimatedValue;
            RecoveryCost = recoveryCost;

            RaiseEvent(new PercentageChangedEvent(this.NotificationId, percentageRecoverable));
        }
 public WasteRecovery(Guid notificationId,
     Percentage percentageRecoverable,
     EstimatedValue estimatedValue,
     RecoveryCost recoveryCost)
 {
     NotificationId = notificationId;
     PercentageRecoverable = percentageRecoverable;
     EstimatedValue = estimatedValue;
     RecoveryCost = recoveryCost;
 }
        private async Task<WasteRecovery> CreateWasteRecovery(NotificationApplication notification)
        {
            var estimatedValue = new EstimatedValue(ValuePerWeightUnits.Kilogram, 10);
            var recoveryCost = new RecoveryCost(ValuePerWeightUnits.Tonne, 50);

            var wasteRecovery = new WasteRecovery(notification.Id, new Percentage(50), estimatedValue, recoveryCost);

            context.WasteRecoveries.Add(wasteRecovery);
            await context.SaveChangesAsync();
            return wasteRecovery;
        }
        private async Task <WasteRecovery> CreateWasteRecovery(NotificationApplication notification)
        {
            var estimatedValue = new EstimatedValue(ValuePerWeightUnits.Kilogram, 10);
            var recoveryCost   = new RecoveryCost(ValuePerWeightUnits.Tonne, 50);

            var wasteRecovery = new WasteRecovery(notification.Id, new Percentage(50), estimatedValue, recoveryCost);

            context.WasteRecoveries.Add(wasteRecovery);
            await context.SaveChangesAsync();

            return(wasteRecovery);
        }