Exemplo n.º 1
0
        public SapMtkModel GuiaAcademicaBusiness(GuiaAcademicaModel request)
        {
            SapMtkModel response = null;

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

                    response.PrimerNombre               = request.PrimerNombre;
                    response.Ciudad                     = request.Ciudad;
                    response.Email                      = request.Email;
                    response.NumeroTelefono             = request.NumeroTelefono;
                    response.AutorizoUsoDatosPersonales = request.AutorizoUsoDatosPersonales;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                throw new Exception("El modelo esta vacio");
            }

            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Post GuiaAcademica
        /// </summary>
        /// <param name="datosFormulario"></param>
        /// <returns></returns>
        public HttpResponseMessage PostGuiaAcademica([FromBody] string product)
        {
            if (string.IsNullOrEmpty(product))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Modelo de datos inválido"));
            }

            GuiaAcademicaModel request = null;

            request = new GuiaAcademicaModel();

            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("Ciudad"))
                {
                    request.Ciudad = kv.Value;
                }
                if (kv.Key.Contains("Email"))
                {
                    request.Email = kv.Value;
                }
                if (kv.Key.Contains("NumeroTelefono"))
                {
                    request.NumeroTelefono = kv.Value;
                }
                if (kv.Key.Contains("AutorizoUsoDatosPersonales"))
                {
                    request.AutorizoUsoDatosPersonales = kv.Value;
                }
            }

            ApiBusiness mapeoDatos = new ApiBusiness();

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

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