Пример #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));
     }
 }
Пример #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;
        }
Пример #3
0
 public static Money FromString(string amount, string currency, IcurrencyLookup currencyLookup) => new Money(decimal.Parse(amount), currency, currencyLookup);
Пример #4
0
 public static Money FromDecimal(decimal amount, string currency, IcurrencyLookup currencyLookup) => new Money(amount, currency, currencyLookup);
Пример #5
0
 public new static Price FromDecimal(decimal amount, string currency, IcurrencyLookup currencyLookup) => new Price(amount, currency, currencyLookup);
Пример #6
0
 public ClassfiedAdApplicationService(IClassifiedAdRepository repository, IUnitOfWork unitOfWork, IcurrencyLookup currencyLookup)
 {
     _currencyLookup = currencyLookup;
     _unitOfWork     = unitOfWork;
     _repository     = repository;
 }