public ActionResult Contact(EntidadVuelo model) { try { if (ModelState.IsValid) { string url = "http://testapi.vivaair.com/otatest/api/values"; string method = "POST"; string fecha = model.From.ToString("yyyy-MM-dd"); VueloEnt vueloEnt = new VueloEnt(); VuelosNeg vuelosNeg = new VuelosNeg(); vueloEnt.Origin = model.Origin; vueloEnt.Destination = model.Destination; vueloEnt.From = fecha; string json = Newtonsoft.Json.JsonConvert.SerializeObject(vueloEnt); string rest = vuelosNeg.GetVuelos(url, json, method); rest = rest.TrimStart('\"'); rest = rest.TrimEnd('\"'); rest = rest.Replace("\\", ""); List <RespuestaVuelos> vuelosList = JsonConvert.DeserializeObject <List <RespuestaVuelos> >(rest); return(View(vuelosList)); } return(Redirect("Index")); } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { string url = "http://testapi.vivaair.com/otatest/api/values"; string method = "POST"; VueloEnt vueloEnt = new VueloEnt(); VuelosNeg vuelosNeg = new VuelosNeg(); vueloEnt.Origin = "BOG"; vueloEnt.Destination = "CTG"; vueloEnt.From = "2020-09-30"; string json = Newtonsoft.Json.JsonConvert.SerializeObject(vueloEnt); // var rest = vuelosNeg.GetVuelos(url, json, method); }