Esempio n. 1
0
        public QueryValidator(INBPClient client)
        {
            RuleFor(x => x.Amount)
            .Cascade(CascadeMode.Stop)
            .NotEmpty()
            .WithMessage("You must provide amount")
            .Must(x => x > 0)
            .WithMessage("Amount must be greater than 0");

            RuleFor(x => x.SourceCurrency)
            .Cascade(CascadeMode.Stop)
            .NotEmpty()
            .WithMessage("You must provide source currency")
            .MustAsync(async(SourceCurrency, cancellation) => SourceCurrency == "PLN" || await client.CheckIfCurrencyExists(SourceCurrency))
            .WithMessage("Provided source currency code does not exist")
            .Must((query, sourceCurrency) => sourceCurrency != query.TargetCurrency)
            .WithMessage("Source currency must be different than target currency");

            RuleFor(x => x.TargetCurrency)
            .Cascade(CascadeMode.Stop)
            .NotEmpty()
            .WithMessage("You must provide target currency")
            .MustAsync(async(TargetCurrency, cancellation) => TargetCurrency == "PLN" || await client.CheckIfCurrencyExists(TargetCurrency))
            .WithMessage("Provided target currency code does not exist");
        }
 public CurrencyService(INBPClient client,
                        IEventService eventService,
                        IValidator <Query> queryValidator)
 {
     _nbpClient      = client;
     _eventService   = eventService;
     _queryValidator = queryValidator;
 }
Esempio n. 3
0
 public NBPService(INBPClient nbpClient)
 {
     _NBPkClient = nbpClient;
 }
 public CurrencyController(ICurrencyService currencyService,
                           INBPClient nbpClient)
 {
     _currencyService = currencyService;
     _nbpClient       = nbpClient;
 }