public ActionResult Get([FromHeader] string authorization, [FromQuery] string origen, [FromQuery] string destino,
                                [FromQuery] string fechaSalida, [FromQuery] string fechaLlegada, [FromQuery] string personas)
        {
            if (String.IsNullOrEmpty(authorization) || !validateToken(authorization))
            {
                return(Unauthorized("Token invalido"));
            }
            List <Hotel> hoteles            = hotelesCollector.GetHoteles(destino, personas);
            var          serializerSettings = new JsonSerializerSettings();

            serializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            string str_hoteles = JsonConvert.SerializeObject(hoteles, serializerSettings);
            string str_vuelos  = "";

            if (fechaLlegada != null && fechaLlegada != "")
            {
                str_vuelos = JsonConvert.SerializeObject(vuelosCollector.GetVuelosIdaVuelta(origen, destino, fechaSalida, fechaLlegada, personas), serializerSettings);
            }
            else
            {
                str_vuelos = JsonConvert.SerializeObject(vuelosCollector.GetVuelosIda(origen, destino, fechaSalida, personas), serializerSettings);
            }
            string hoteles_vuelos = "{\"hoteles\":" + str_hoteles + ", \"vuelos\":" + str_vuelos + "}";

            return(Ok(hoteles_vuelos));
        }
Exemple #2
0
 public ActionResult Get([FromHeader] string authorization, [FromQuery] string origen, [FromQuery] string destino,
                         [FromQuery] string fechaSalida, [FromQuery] string fechaLlegada, [FromQuery] string personas)
 {
     if (String.IsNullOrEmpty(authorization) || !validateToken(authorization))
     {
         return(Unauthorized("Token invalido"));
     }
     if (fechaLlegada != null && fechaLlegada != "")
     {
         return(Ok(vuelosCollector.GetVuelosIdaVuelta(origen, destino, fechaSalida, fechaLlegada, personas)));
     }
     else
     {
         return(Ok(vuelosCollector.GetVuelosIda(origen, destino, fechaSalida, personas)));
     }
 }