Exemple #1
0
        public async Task CreateExchangeRateFactors(ExchangeRateFactors factors)
        {
            var sqlFactors = _mapper.Map <Model.ExchangeRateFactors>(factors);

            _context.ExchangeRateFactors.Add(sqlFactors);
            await _context.SaveChangesAsync();
        }
 private void ValidateExchangeRateFactors(ExchangeRateFactors factors)
 {
     if (factors.Date.Year < 1991 || factors.Date.Date > DateTime.Now)
     {
         throw new DomainErrorException($"Date should be greater than 1991-01-01 and less than {DateTime.Now.ToString("d")}");
     }
     if (factors.ExchangeRateUSD < 0)
     {
         throw new DomainErrorException("ExchangeRateUSD should be greater than 0");
     }
     if (factors.ExchangeRateEUR < 0)
     {
         throw new DomainErrorException("ExchangeRateEUR should be greater than 0");
     }
     if (factors.CreditRate < 0)
     {
         throw new DomainErrorException("CreditRate should be greater than 0");
     }
     if (factors.ExportIndicator < 0)
     {
         throw new DomainErrorException("ExportIndicator should be greater than 0");
     }
     if (factors.ImportIndicator < 0)
     {
         throw new DomainErrorException("ImportIndicator should be greater than 0");
     }
     if (factors.InflationIndex < 0)
     {
         throw new DomainErrorException("InflationIndex should be greater than 0");
     }
     if (factors.GDPIndicator < 0)
     {
         throw new DomainErrorException("GDPIndicator should be greater than 0");
     }
 }
Exemple #3
0
        public async Task UpdateExchangeRateFactors(ExchangeRateFactors factors)
        {
            var sqlFactors      = _mapper.Map <Model.ExchangeRateFactors>(factors);
            var attachedFactors = _context.ExchangeRateFactors.Attach(sqlFactors);

            attachedFactors.State = EntityState.Modified;
            await _context.SaveChangesAsync();
        }
        public async Task UpdateExchangeRateFactors(ExchangeRateFactors factors)
        {
            ValidateExchangeRateFactors(factors);
            var doesExist = await _exchangeRateFactorsRepository.DoesExchangeRateFactorsExist(factors.Date);

            if (!doesExist)
            {
                throw new DomainErrorException($"Exchange rate factors with date = {factors.Date.ToString("d")} doesn't exist in db");
            }

            await _exchangeRateFactorsRepository.UpdateExchangeRateFactors(factors);
        }
 public Task CreateExchangeRateFactors([FromBody] ExchangeRateFactors request)
 {
     return(_exchangeRateFactorsService.CreateExchangeRateFactors(request));
 }
 public Task UpdateExchangeRateFactors(int id, [FromBody] ExchangeRateFactors request)
 {
     request.Id = id;
     return(_exchangeRateFactorsService.UpdateExchangeRateFactors(request));
 }
        public float PredictEURCurrencyExchange(ExchangeRateFactors factors)
        {
            var input = _mapper.Map <CurrencyExchangeModelInput>(factors);

            return(EURCurrencyExchangeConsumeModel.Predict(input).Score);
        }