Ejemplo n.º 1
0
        public JsonResult Comentar(Testimonio testimonio)
        {
            //const string FMT = "yyyy-MM-dd";
            //System.Web.HttpContext context = System.Web.HttpContext.Current;
            //string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            //var rm = new ResponseModel();

            // if (ModelState.IsValid)
            //{                
            //testimonio.Usuario_id = FrontOfficeStartUp.Usuariovisualizando();
            //testimonio.IP = ipAddress;
            //testimonio.Fecha = DateTime.Now.ToString(FMT);
            //testimonio.estado = 2;
            //rm = testimonio.Guardar();
            //rm.SetResponse(true);
            // }

            var rm = new ResponseModel();

            if (ModelState.IsValid)
            {
                rm = testimonio.Guardar();

                if (rm.response) rm.message = "Gracias por comentar";
            }

            return Json(rm);

        }
Ejemplo n.º 2
0
        public ActionResult Crud(int id)
        {
            if (id != 0)
            {
                testimonio = testimonio.Obtener(id);
            }

            return(View(testimonio));
        }
Ejemplo n.º 3
0
        public ActionResult Crud(int id = 0)
        {
            Testimonio testmonio = new Testimonio();

            testimonio.Usuario_id = 3;
            if (id != 0)
            {
                testimonio = testimonio.Obtener(id);
            }
            return(View(testimonio));
        }
Ejemplo n.º 4
0
        public JsonResult Guardar(Testimonio model)
        {
            ResponseModel rm = new ResponseModel();

            rm = model.Guardar();

            if (rm.response)
            {
                rm.href = "/Admin/Testimonios";
            }

            return(Json(rm));
        }
        public ActionResult crud(int id = 0)
        {
            if (id == 0)
            {
                testimonio.Usuario_id = SessionHelper.GetUser();
            }
            else
            {
                testimonio = testimonio.Obtener(id);
            }

            return(View(testimonio));
        }
Ejemplo n.º 6
0
        public JsonResult Guardar(Testimonio model)
        {
            var rm = new ResponseModel();

            if (ModelState.IsValid)
            {
                rm = model.Guardar();
                if (rm.response)
                {
                    rm.href = Url.Content("~/Admin/Testimonios");
                }
            }
            return(Json(rm));
        }
Ejemplo n.º 7
0
        public JsonResult GuardarTestimonio(Testimonio model)
        {
            var rm = new ResponseModel();

            if (ModelState.IsValid)
            {
                rm = model.Guardar();
                if (rm.response)
                {
                    rm.message = "Gracias por comentar";
                }
            }
            return(Json(rm));
        }
        //problema de redireccionamiento. Solucionarlo en varios lugares.

        //public JsonResult SaveTestimony(Testimonio model)
        //{
        //    var rm = new ResponseModel();

        //    if (ModelState.IsValid)
        //    {
        //        rm = model.Save();

        //        if (rm.response)
        //        {
        //            rm.message = "Gracias por comentar";
        //            rm.href = Url.Content("~/");
        //        }
        //    }

        //    return Json(rm);
        //}

        public RedirectResult SaveTestimony(Testimonio model)
        {
            var rm = new ResponseModel();

            if (ModelState.IsValid)
            {
                rm = model.Save();

                if (rm.response)
                {
                    rm.message = "Gracias por comentar";
                }
            }

            return(Redirect("~/Default/Index"));
        }
        public ActionResult Crud(int id = 0)
        {
            testimonio = testimonio.getTestimony(id);

            return(View(testimonio));
        }
Ejemplo n.º 10
0
        private async void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            Testimonio objTestimonio = new Testimonio();

            objTestimonio.name  = txtNombre.Text;
            objTestimonio.email = txtCorreo.Text;
            //objTestimonio.category = txtCategoria.Text;

            objTestimonio.category    = "Justicia en las familias";
            objTestimonio.explanation = txtExplicacion.Text;
            //objTestimonio.state = lstEntidad.SelectedIndex.ToString();
            objTestimonio.state  = "6";
            objTestimonio.age    = (lstEdad.SelectedItem as ListBoxItem).Content.ToString();
            objTestimonio.gender = (lstGenero.SelectedItem as ListBoxItem).Content.ToString();
            objTestimonio.grade  = (lstEscolaridad.SelectedItem as ListBoxItem).Content.ToString();


            //await objEndpoint.postExpediente(objExpediente);

            /*
             * HttpClient httpClient = new HttpClient();
             * var response = await httpClient.GetAsync("http://www.factico.com.mx/CIDE/APIBeta/expediente.php?q=getList");
             *
             * var responseString = await response.Content.ReadAsStringAsync();
             * var serializer = new JsonSerializer();
             * var values = serializer.Deserialize<List<responseJSON>>(new JsonTextReader(new StringReader(responseString)));*/

            var sets = new JsonSerializerSettings();

            sets.ContractResolver = new interfaceExpediente(ExpedienteReveiceType.PostNG);


            Book book = new Book
            {
                BookName      = "The Gathering Storm",
                BookPrice     = 16.19m,
                AuthorName    = "Brandon Sanderson",
                AuthorAge     = 34,
                AuthorCountry = "United States of America"
            };

            string startingWithA = JsonConvert.SerializeObject(objTestimonio, Formatting.Indented,
                                                               new JsonSerializerSettings {
                ContractResolver = new DynamicContractResolver('g')
            });

            string startingWithB = JsonConvert.SerializeObject(book, Formatting.Indented,
                                                               new JsonSerializerSettings {
                ContractResolver = new DynamicContractResolver('n')
            });

            //string strJSON = JsonConvert.SerializeObject(objExpediente, Formatting.Indented, setts);
            string      strJSON = JsonConvert.SerializeObject(objTestimonio, Formatting.None);
            HttpContent content = new StringContent(strJSON);

            /*var content = new FormUrlEncodedContent(new[]
             * {
             *  new KeyValuePair<string, string>("nombre", objExpSource.nombre),
             *  new KeyValuePair<string, string>("correo", objExpSource.correo),
             *  new KeyValuePair<string, string>("categoria", objExpSource.categoria),
             *  new KeyValuePair<string, string>("explicacion", objExpSource.explicacion),
             *  new KeyValuePair<string, string>("entidad", objExpSource.entidad),
             *  new KeyValuePair<string, string>("edad", objExpSource.edad),
             *  new KeyValuePair<string, string>("genero", objExpSource.genero),
             *  new KeyValuePair<string, string>("escolaridad", objExpSource.escolaridad)
             *
             * });*/



            HttpClient httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var response = await httpClient.PostAsync("http://www.justiciacotidiana.mx:8080/justiciacotidiana/api/v1/testimonios", content);

            var responseString = await response.Content.ReadAsStringAsync();

            var serializer = new JsonSerializer();



            var values = serializer.Deserialize(new StringReader(responseString), typeof(responseJSON));
        }