Exemple #1
0
        public ActionResult GetTaxa()
        {
            try
            {
                using (var client = new TesteSfotPlanClient(_config))
                {
                    var obj = new object();

                    var response = client.Client.GetAsync(rotaApi + "taxajuros").Result;

                    if (!response.IsSuccessStatusCode)
                    {
                        obj = new { data = "", erro = "Erro ao retornar taxa:" + response.StatusCode.ToString() };
                    }
                    else
                    {
                        obj = new { data = JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), erro = "" }
                    };



                    return(new JsonResult(obj));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Exemple #2
0
        public ActionResult CalcularTaxa(decimal valorinicial, int meses)
        {
            try
            {
                using (var client = new TesteSfotPlanClient(_config))
                {
                    var obj = new object();

                    var value = new Dictionary <string, string>
                    {
                        { "valorinicial", valorinicial.ToString() },
                        { "meses", meses.ToString() }
                    };

                    var response = client.Client.PostAsync(rotaApi + "calculajuros?valorinicial=" + valorinicial + "&meses=" + meses, null).Result;

                    if (!response.IsSuccessStatusCode)
                    {
                        obj = new { data = "", erro = "Erro ao retornar taxa:" + response.StatusCode.ToString() };
                    }
                    else
                    {
                        obj = new { data = JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result).Replace(".", ","), erro = "" }
                    };

                    return(new JsonResult(obj));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Exemple #3
0
        public IActionResult Index()
        {
            try
            {
                using (var client = new TesteSfotPlanClient(_config))
                {
                    var link = client.Client.GetAsync(rotaApi + "showmethecode").Result;

                    if (link.IsSuccessStatusCode)
                    {
                        ViewBag.LinkProjeto = JsonConvert.DeserializeObject <string>(link.Content.ReadAsStringAsync().Result);
                    }

                    ViewBag.LinkProjeto = string.Empty;
                }

                return(View());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }