.Net Asp.Net MVC C# Development

Reading Json

public double ConvertRate(double amount=5, string from="USD", string to="AED")
        {
            double x;
            try
            {
            string str= "https://free.currconv.com/api/v7/convert?q="+from+"_"+to+"&compact=ultra&apiKey=f32acb5e280413fa3277";
            var httpclient = new HttpClient();
            var response = httpclient.GetAsync(str);
            var resp = response.Result.Content.ReadAsStringAsync();
            var data = (JObject)JsonConvert.DeserializeObject(resp.Result.ToString());
            return data.First.First.Value<double>();
            }
            catch (Exception E)
            {
                return 0;
            }
            
            //return (x*amount).ToString();
        }

Leave a Reply

Your email address will not be published. Required fields are marked *