Example #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);
        }
Example #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);
        }
Example #5
0
        public void Update(Percentage percentageRecoverable,
                           EstimatedValue estimatedValue,
                           RecoveryCost recoveryCost)
        {
            PercentageRecoverable = percentageRecoverable;
            EstimatedValue        = estimatedValue;
            RecoveryCost          = recoveryCost;

            RaiseEvent(new PercentageChangedEvent(this.NotificationId, percentageRecoverable));
        }
Example #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;
 }
Example #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;
        }
Example #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);
     }
 }
        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);
        }
Example #13
0
 public bool Equals(FlashObservation other)
 {
     return(ObservationPoint == other.ObservationPoint && ObservationTime == other.ObservationTime &&
            EstimatedValue.CompareTo(other.EstimatedValue, Precision) == 0);
 }
Example #14
0
 public override string ToString()
 {
     return($"FlashObservation: ObservationPoint = {ObservationPoint.ToString()}, Intensity = {Intensity.ToString()}, " +
            $"Duration(ms) = {DurationMs.ToString()}, ObservationTime = {ObservationTime.ToString()}, EstimatedValue = {EstimatedValue.ToString()}");
 }
Example #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));
 }
Example #16
0
 public override string ToString()
 {
     // ReSharper disable LocalizableElement
     return(string.Format("{0} SE {1}", EstimatedValue.ToString("0.####"), StandardError.ToString("0.####")));
     // ReSharper restore LocalizableElement
 }