コード例 #1
0
        public static string KurDegerAl(DateTime date, ExchangeRateCurrencyCodes code, ExchangeOperations islem)
        {
            string tur       = islem.ToString();
            string dovizCode = code.ToString();

            string KurDeger = String.Empty;

            //string YilAy = DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString()
            for (int i = 0; i > -29; i--)
            {
                try
                {
                    DateTime tarih   = date.AddDays(i);
                    string   Yil     = tarih.Year.ToString();
                    string   Ay      = tarih.Month > 9 ? tarih.Month.ToString() : "0" + tarih.Month.ToString();
                    string   Gun     = tarih.Day > 9 ? tarih.Day.ToString() : "0" + tarih.Day.ToString();
                    string   newPath = "http://www.tcmb.gov.tr/kurlar/" + Yil + Ay + "/" + Gun + Ay + Yil + ".xml";

                    KurDeger = KurXmlGetir(newPath, dovizCode, tur);
                    if (!String.IsNullOrEmpty(KurDeger))
                    {
                        break;
                    }
                }
                catch (Exception)
                {
                }
            }
            return(KurDeger);
        }
コード例 #2
0
 public async Task <IActionResult> GetQuotation(ExchangeRateCurrencyCodes currencyCode,
                                                Segment segment, ulong amountToBy)
 {
     try
     {
         _logger.LogInformation($"{DateTime.Now:u}|Starting Calculate Quotation");
         var result = QuotationSvc.Calculate(
             await ExchangeRateSvc.GetLatestRates(),
             await SegmentTaxSvc.GetCustomerSegmentTax(segment),
             amountToBy);
         _logger.LogInformation($"{DateTime.Now:u}|Customer Quotation is {result.Total}");
         return(Ok(result));
     }
     catch (Exception ex)
     {
         _logger.LogError($"{DateTime.Now:u}|{ex.Message}|{ex.StackTrace}");
         return(BadRequest(ex.Message));
     }
 }
コード例 #3
0
 internal string GetExchangeRateValue(DateTime date, ExchangeRateCurrencyCodes code, ExchangeOperations operation)
 {
     return(DovizIslemleri.KurDegerAl(DateTime.Today, code, operation));
 }