Exemple #1
0
        public SapMtkModel ProgramaContinuadaBusiness(ProgramaContinuadaModel request)
        {
            SapMtkModel response = null;

            if (request != null)
            {
                try
                {
                    response = new SapMtkModel();

                    response.PrimerNombre                 = request.PrimerNombre;
                    response.Apellidos                    = request.Apellidos;
                    response.Email                        = request.Email;
                    response.NumeroTelefono               = request.NumeroTelefono;
                    response.TipoIdentificacion           = request.TipoIdentificacion;
                    response.NumeroIdentificacion         = request.NumeroIdentificacion;
                    response.ComoPrefieresContactemos     = request.ComoPrefieresContactemos;
                    response.HorarioPrefiereSerContactado = request.HorarioPrefiereSerContactado;
                    response.SeleccionaCiudad             = request.SeleccionaCiudad;
                    response.CuandoQuieresIniciarClase    = request.CuandoQuieresIniciarClase;
                    response.ComoNosConociste             = request.ComoNosConociste;
                    response.ReferidoEANSINO              = request.ReferidoEANSINO;
                    response.Comentarios                  = request.Comentarios;
                    response.AutorizoUsoDatosPersonales   = request.AutorizoUsoDatosPersonales;
                    response.ProgramaAcademico            = request.ProgramaAcademico;
                    response.URLreferencia                = request.URLreferencia;
                    response.URLOrigen                    = request.URLOrigen;
                    response.UTMSource                    = request.UTMSource;
                    response.UTMMedium                    = request.UTMMedium;
                    response.UTMCampaing                  = request.UTMCampaing;
                    response.UTMTerm                      = request.UTMTerm;
                    response.UTMContent                   = request.UTMContent;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                throw new Exception("El modelo esta vacio");
            }

            return(response);
        }
Exemple #2
0
        ////// POST: api/ApiLeads
        //public void Post([FromBody]string value)
        //{
        ////    //ApiFactory factory = new ConcreteApiFactory();

        ////    //ISapMtk margarita = factory.GetApis(Nombre, string Modelo);
        ////    //return new string[] { $"La {Nombre} cuesta {margarita.getPrice()} euros" };



        //}

        /// <summary>
        /// Post Formulario Programas Continuada - Formal
        /// </summary>
        /// <param name="datosFormulario"></param>
        /// <returns></returns>
        public IHttpActionResult PostProgramaContinuada(ProgramaContinuadaModel datosFormulario)
        {
            ApiBusiness mapeoDatos = new ApiBusiness();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Modelo de datos inválido"));
                }

                var response = mapeoDatos.ProgramaContinuadaBusiness(datosFormulario);

                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest("mensaje de error: " + e.Message));
            }
        }
Exemple #3
0
        //public HttpResponseMessage Post([FromBody] Product product)
        //public HttpResponseMessage PostProgramaContinuada([FromBody] ForProgramasContinuadaFormalModel datosFormulario)
        //public IHttpActionResult PostProgramaContinuada(ProgramaContinuadaModel datosFormulario)
        // public IHttpActionResult PostProgramaContinuada(string datosFormulario)
        //public void Post([FromBody]string value)
        public HttpResponseMessage Post([FromBody] string product)
        {
            ProgramaContinuadaModel request = null;

            request = new ProgramaContinuadaModel();

            Dictionary <string, string> j = JsonConvert.DeserializeObject <Dictionary <string, string> >(product);
            dynamic pr = JsonConvert.DeserializeObject(product);

            foreach (var kv in j)
            {
                if (kv.Key.Contains("primer nombre"))
                {
                    request.PrimerNombre = kv.Value;
                }
                //var g = kv.Key.Replace(" ", "_");
                //Console.WriteLine(g);
            }



            //var definicion = new { Codigo = "", Cantidad = 0 };
            //var listaDefinicion = new[] { definicion };

            //var productos = "[{\"codigo1\":\"Servilleta\",\"cantidad\":2},{\"codigo\":\"Papelhig\",\"cantidad\":1}]";

            //var listProductos = JsonConvert.DeserializeAnonymousType(productos, listaDefinicion);

            //foreach (var prod in listProductos)
            //{
            //    Console.WriteLine("Código: " + prod.Codigo + " - Cantidad: " + prod.Cantidad);
            //}



            //string j = Newtonsoft.Json.JsonConvert.SerializeObject(product);

            //string json = "{\"Description\":\" Compartir conocimiento \",\"Name 1\":\"estradawebgroup\"}";
            ////dynamic pr = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
            ////string p = ((Newtonsoft.Json.Linq.JProperty)(Newtonsoft.Json.Linq.JToken>(((Newtonsoft.Json.Linq.JObject)pr).ChildrenTokens).Items[0])).Name;
            //using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(product)))
            //{
            //    // Deserialization from JSON
            //    DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(Blog));
            //    Blog bsObj2 = (Blog)deserializer.ReadObject(ms);
            //    //Response.Write("Name: " + bsObj2.Name); // Name: estradawebgroup
            //    //Response.Write("Description: " + bsObj2.Description); // Description: Compartir conocimiento
            //}



            //*******************************************************
            ApiBusiness mapeoDatos = new ApiBusiness();

            try
            {
                //if (!ModelState.IsValid)
                // return BadRequest("Modelo de datos inválido");

                //var response = mapeoDatos.ProgramaContinuadaBusiness(datosFormulario);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Data not inserted"));
                //return Ok("aaaaaaa");
            }
            catch (Exception e)
            {
                //return BadRequest("mensaje de error: " + e.Message);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Data not inserted"));
            }

            //*******************************************************

            //try
            //{
            //    Entities.Products.Add(product);
            //    Entities.SaveChanges();
            //    var response = Request.CreateResponse(HttpStatusCode.Created, product);
            //    response.Headers.Location = Request.RequestUri;

            //    return response;
            //}
            //catch (Exception)
            //{
            //    return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Data not inserted");
            //}
        }
Exemple #4
0
        /// <summary>
        /// Post ProgramaContinuada
        /// </summary>
        /// <param name="datosFormulario"></param>
        /// <returns></returns>
        public HttpResponseMessage PostProgramaContinuada([FromBody] string product)
        {
            if (string.IsNullOrEmpty(product))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Modelo de datos inválido"));
            }

            ProgramaContinuadaModel request = null;

            request = new ProgramaContinuadaModel();

            Dictionary <string, string> j = JsonConvert.DeserializeObject <Dictionary <string, string> >(product);
            dynamic pr = JsonConvert.DeserializeObject(product);

            foreach (var kv in j)
            {
                if (kv.Key.Contains("PrimerNombre"))
                {
                    request.PrimerNombre = kv.Value;
                }
                if (kv.Key.Contains("Apellidos"))
                {
                    request.Apellidos = kv.Value;
                }
                if (kv.Key.Contains("Email"))
                {
                    request.Email = kv.Value;
                }
                if (kv.Key.Contains("NumeroTelefono"))
                {
                    request.NumeroTelefono = kv.Value;
                }
                if (kv.Key.Contains("TipoIdentificacion"))
                {
                    request.TipoIdentificacion = kv.Value;
                }
                if (kv.Key.Contains("NumeroIdentificacion"))
                {
                    request.NumeroIdentificacion = kv.Value;
                }
                if (kv.Key.Contains("ComoPrefieresContactemos"))
                {
                    request.ComoPrefieresContactemos = kv.Value;
                }
                if (kv.Key.Contains("HorarioPrefiereSerContactado"))
                {
                    request.HorarioPrefiereSerContactado = kv.Value;
                }
                if (kv.Key.Contains("SeleccionaCiudad"))
                {
                    request.SeleccionaCiudad = kv.Value;
                }
                if (kv.Key.Contains("CuandoQuieresIniciarClase"))
                {
                    request.CuandoQuieresIniciarClase = kv.Value;
                }
                if (kv.Key.Contains("ComoNosConociste"))
                {
                    request.ComoNosConociste = kv.Value;
                }
                if (kv.Key.Contains("ReferidoEANSINO"))
                {
                    request.ReferidoEANSINO = kv.Value;
                }
                if (kv.Key.Contains("Comentarios"))
                {
                    request.Comentarios = kv.Value;
                }
                if (kv.Key.Contains("AutorizoUsoDatosPersonales"))
                {
                    request.AutorizoUsoDatosPersonales = kv.Value;
                }
                if (kv.Key.Contains("ProgramaAcademico"))
                {
                    request.ProgramaAcademico = kv.Value;
                }
                if (kv.Key.Contains("URLreferencia"))
                {
                    request.URLreferencia = kv.Value;
                }
                if (kv.Key.Contains("URLOrigen"))
                {
                    request.URLOrigen = kv.Value;
                }
                if (kv.Key.Contains("UTMSource"))
                {
                    request.UTMSource = kv.Value;
                }
                if (kv.Key.Contains("UTMMedium"))
                {
                    request.UTMMedium = kv.Value;
                }
                if (kv.Key.Contains("UTMCampaing"))
                {
                    request.UTMCampaing = kv.Value;
                }
                if (kv.Key.Contains("UTMTerm"))
                {
                    request.UTMTerm = kv.Value;
                }
                if (kv.Key.Contains("UTMContent"))
                {
                    request.UTMContent = kv.Value;
                }
            }

            ApiBusiness mapeoDatos = new ApiBusiness();

            try
            {
                var response = mapeoDatos.ProgramaContinuadaBusiness(request);

                return(Request.CreateResponse(HttpStatusCode.Accepted, "Modelo enviado"));
            }
            catch (Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "mensaje de error: " + e.Message));
            }
        }