Пример #1
0
 public static PriceEntity Multiply(PriceEntity p, decimal multiplier)
 {
     if (!p.IsEligible())
     {
         return(CALL_PRICING);
     }
     return(new PriceEntity()
     {
         value = p.value * multiplier, currency = p.currency
     });
 }
Пример #2
0
 public static PriceEntity Divide(PriceEntity p, int divisor)
 {
     if (!p.IsEligible())
     {
         return(CALL_PRICING);
     }
     return(new PriceEntity()
     {
         value = p.value / divisor, currency = p.currency
     });
 }
Пример #3
0
 public static PriceEntity Add(PriceEntity p, PriceEntity add)
 {
     if (!p.IsEligible() && !add.IsEligible())
     {
         return(CALL_PRICING);
     }
     if (p.currency != add.currency)
     {
         // currency mismatch
         return(p);
     }
     return(new PriceEntity()
     {
         value = p.value + add.value, currency = p.currency
     });
 }
Пример #4
0
 public static PriceEntity Subtract(PriceEntity p, PriceEntity sub)
 {
     if (!p.IsEligible() && !sub.IsEligible())
     {
         return(CALL_PRICING);
     }
     if (p.currency != sub.currency)
     {
         // currency mismatch
         return(p);
     }
     return(new PriceEntity()
     {
         value = p.value - sub.value, currency = p.currency
     });
 }