Beispiel #1
0
 private Price(decimal amount, string currencyCode, IcurrencyLookup currencyLookup) : base(amount, currencyCode, currencyLookup)
 {
     if (amount < 0)
     {
         throw new ArgumentException("Price cannot be negative", nameof(amount));
     }
 }
Beispiel #2
0
        protected Money(decimal amount, string currencyCode, IcurrencyLookup currencyLookup)
        {
            if (string.IsNullOrEmpty(currencyCode))
            {
                throw new ArgumentNullException(nameof(currencyCode), "Currency code must be specified");
            }

            CurrencyDetails currency = currencyLookup.FindCurrency(currencyCode);

            if (!currency.InUse)
            {
                throw new ArgumentException($"Currency {currencyCode} is not valid");
            }

            if (decimal.Round(amount, currency.DecimalPlaces) != amount)
            {
                throw new ArgumentOutOfRangeException(nameof(amount), $"Amount in {currencyCode} cannot have more than {currency.DecimalPlaces} decimals");
            }

            Amount   = amount;
            Currency = currency;
        }
Beispiel #3
0
 public static Money FromString(string amount, string currency, IcurrencyLookup currencyLookup) => new Money(decimal.Parse(amount), currency, currencyLookup);
Beispiel #4
0
 public static Money FromDecimal(decimal amount, string currency, IcurrencyLookup currencyLookup) => new Money(amount, currency, currencyLookup);
Beispiel #5
0
 public new static Price FromDecimal(decimal amount, string currency, IcurrencyLookup currencyLookup) => new Price(amount, currency, currencyLookup);
 public ClassfiedAdApplicationService(IClassifiedAdRepository repository, IUnitOfWork unitOfWork, IcurrencyLookup currencyLookup)
 {
     _currencyLookup = currencyLookup;
     _unitOfWork     = unitOfWork;
     _repository     = repository;
 }