示例#1
0
 /// <summary>
 /// Get the value of the PPC given a CurrencyCode.  PPC validation is done first.
 /// </summary>
 /// <param name="ppc">Ppc to get amount for</param>
 /// <param name="pin">Ppc PIN</param>
 /// <param name="currencyCode">Currency to get amount for</param>
 /// <returns>Amount in Currency</returns>
 static public decimal GetPpcAmount(Ppc ppc, string pin, string currencyCode)
 {
     ErrorCode valid = Validate(ppc, pin, currencyCode);
     if (valid == ErrorCode.Success)
     {
         //var ppcValue = ppc.PpcType.PpcTypeCurrencies.FirstOrDefault(c => c.CurrencyCode == currencyCode);
         //if (ppcValue == null)
         //{
         //    throw new Exception("Invalid currency code.");
         //}
         //else
         //{
         //    return (ppcValue.Amount);
         //}
         return ppc.GetAmount(currencyCode);
     }
     else
     {
         throw new Exception(valid.ToString());
     }
 }
示例#2
0
 /// <summary>
 /// Validate a given serialNumber and pin
 /// </summary>
 /// <param name="ppc">PPC object to be validated</param>
 /// <param name="pin">PPC pin</param>
 /// <param name="currencyCode">Check if PPC is valid for use with this currency</param>
 /// <returns>ErrorCode.Succress if valid, otherwise, see other values</returns>
 private static ErrorCode Validate(Ppc ppc, string pin, string currencyCode)
 {
     if (ppc == null)
         return (ErrorCode.InvalidSerialNumber);
     else
         return ppc.Validate(pin, currencyCode);
 }