Example #1
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (InstructionIdentification == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "InstructionIdentification");
     }
     if (CurrencyOfTransfer == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "CurrencyOfTransfer");
     }
     if (InstructedAmount == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "InstructedAmount");
     }
     if (CreditorAccount == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "CreditorAccount");
     }
     if (InstructedAmount != null)
     {
         InstructedAmount.Validate();
     }
     if (ExchangeRateInformation != null)
     {
         ExchangeRateInformation.Validate();
     }
     if (DebtorAccount != null)
     {
         DebtorAccount.Validate();
     }
     if (CreditorAccount != null)
     {
         CreditorAccount.Validate();
     }
 }
Example #2
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (ConsentId == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "ConsentId");
     }
     if (Initiation == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Initiation");
     }
     if (Charges != null)
     {
         foreach (var element in Charges)
         {
             if (element != null)
             {
                 element.Validate();
             }
         }
     }
     if (ExchangeRateInformation != null)
     {
         ExchangeRateInformation.Validate();
     }
     if (Initiation != null)
     {
         Initiation.Validate();
     }
     if (Authorisation != null)
     {
         Authorisation.Validate();
     }
 }
            private ExchangeRateInformation CreateExchangeRateInformation(List <Rate> orderedHistoricRates)
            {
                var minimumRate = orderedHistoricRates.FirstOrDefault();
                var maximumRate = orderedHistoricRates.LastOrDefault();
                var averageRate = orderedHistoricRates.Select(x => x.RateOnDate).Average();

                var result = new ExchangeRateInformation
                {
                    MinimumRate = new RateInfo {
                        Date = minimumRate.Date.ToString("yyyy-MM-dd"), Rate = minimumRate.RateOnDate
                    },
                    MaximumRate = new RateInfo {
                        Date = maximumRate.Date.ToString("yyyy-MM-dd"), Rate = maximumRate.RateOnDate
                    },
                    AverageRate = averageRate
                };

                return(result);
            }
 public Result(ExchangeRateInformation exchangeRateInformation)
 {
     ExchangeRateInformation = exchangeRateInformation;
 }