Esempio n. 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);
        }
Esempio n. 2
0
        public override int GetHashCode()
        {
            var hashCode = ObservationPoint.GetHashCode();

            hashCode = (hashCode * 397) ^ EstimatedValue.GetHashCode();
            hashCode = (hashCode * 397) ^ ObservationTime.GetHashCode();

            return(hashCode);
        }
        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);
        }
Esempio n. 5
0
        public void Update(Percentage percentageRecoverable,
                           EstimatedValue estimatedValue,
                           RecoveryCost recoveryCost)
        {
            PercentageRecoverable = percentageRecoverable;
            EstimatedValue        = estimatedValue;
            RecoveryCost          = recoveryCost;

            RaiseEvent(new PercentageChangedEvent(this.NotificationId, percentageRecoverable));
        }
Esempio n. 6
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;
 }
Esempio n. 9
0
        void IXmlSerializable.WriteXml(XmlWriter writer)
        {
            var xmlSerializer = new XmlSerializer(typeof(Coordinates));

            xmlSerializer.Serialize(writer, ObservationPoint);

            writer.WriteElementString(nameof(Intensity), Intensity.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString(nameof(DurationMs), DurationMs.ToString());
            writer.WriteElementString(nameof(ObservationTime), ObservationTime.ToString(CultureInfo.InvariantCulture));
            writer.WriteElementString(nameof(EstimatedValue), EstimatedValue.ToString(CultureInfo.InvariantCulture));
        }
        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;
        }
Esempio n. 11
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = EstimatedValue.GetHashCode();
         hashCode = (hashCode * 397) ^ StandardError.GetHashCode();
         hashCode = (hashCode * 397) ^ TValue.GetHashCode();
         hashCode = (hashCode * 397) ^ DegreesOfFreedom;
         hashCode = (hashCode * 397) ^ PValue.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
 public bool Equals(FlashObservation other)
 {
     return(ObservationPoint == other.ObservationPoint && ObservationTime == other.ObservationTime &&
            EstimatedValue.CompareTo(other.EstimatedValue, Precision) == 0);
 }
Esempio n. 14
0
 public override string ToString()
 {
     return($"FlashObservation: ObservationPoint = {ObservationPoint.ToString()}, Intensity = {Intensity.ToString()}, " +
            $"Duration(ms) = {DurationMs.ToString()}, ObservationTime = {ObservationTime.ToString()}, EstimatedValue = {EstimatedValue.ToString()}");
 }
Esempio n. 15
0
 private bool Equals(LinearFitResult other)
 {
     return(EstimatedValue.Equals(other.EstimatedValue) && StandardError.Equals(other.StandardError) && TValue.Equals(other.TValue) && DegreesOfFreedom == other.DegreesOfFreedom && PValue.Equals(other.PValue));
 }
Esempio n. 16
0
 public override string ToString()
 {
     // ReSharper disable LocalizableElement
     return(string.Format("{0} SE {1}", EstimatedValue.ToString("0.####"), StandardError.ToString("0.####")));
     // ReSharper restore LocalizableElement
 }