Пример #1
0
        public ActionResult InsertaComunidad(
            HttpPostedFileBase ImgDestino,
            int IdViaje,
            string sNombre,
            string sTestimonio,
            int iCalificacion
            )
        {
            byte[] baImagen = null;
            if (ImgDestino != null && ImgDestino.ContentLength > 0)
            {
                BinaryReader rdrImagen = new BinaryReader(ImgDestino.InputStream);
                baImagen = rdrImagen.ReadBytes((int)ImgDestino.ContentLength);
            }
            cmComunidad Comunidad =
                new cmComunidad
            {
                IdViaje       = IdViaje,
                sNombre       = sNombre,
                sTestimonio   = sTestimonio,
                iCalificacion = iCalificacion,
                ImgDestino    = baImagen
            };
            var                resultado       = new JObject();
            CD_Comunidad       ComunidadTravel = new CD_Comunidad();
            List <cmComunidad> ComunidadT      = new List <cmComunidad>();

            if (ComunidadTravel.bInsertaComunidad(Comunidad))
            {
                resultado["Exito"]       = true;
                ComunidadT               = ComunidadTravel.lsObtieneComunidad();
                resultado["LsComunidad"] =
                    new JArray(
                        from c in ComunidadT
                        select new JObject(
                            new JProperty("Nom", c.sNombre),
                            new JProperty("Tes", c.sTestimonio),
                            new JProperty("Cal", c.iCalificacion),
                            new JProperty("IDes", c.IdViaje),
                            new JProperty("Des", c.sDestino),
                            new JProperty("FR", c.dtFechaRegistro),
                            new JProperty("Img", Convert.ToBase64String(c.ImgDestino))
                            ));
            }
            else
            {
                resultado["Exito"] = false;
            }
            return(Content(resultado.ToString()));
        }
Пример #2
0
        public ActionResult InicioComunidad()
        {
            var resultado = new JObject();

            try
            {
                CD_Destinos        cdDestino       = new CD_Destinos();
                List <TO_Destino>  lsDestinos      = new List <TO_Destino>();
                CD_Comunidad       ComunidadTravel = new CD_Comunidad();
                List <cmComunidad> ComunidadT      = new List <cmComunidad>();
                lsDestinos = cdDestino.lsObtieneDestinos();
                if (lsDestinos.Count > 0)
                {
                    JToken arDestinos = new JArray(from d in lsDestinos
                                                   select new JObject(
                                                       new JProperty("Viaje", d.IdViaje),
                                                       new JProperty("Destino", d.Destino)
                                                       ));
                    resultado["LsDestinos"] = arDestinos;
                    resultado["Exito"]      = true;
                    ComunidadT = ComunidadTravel.lsObtieneComunidad();
                    resultado["LsComunidad"] =
                        new JArray(
                            from c in ComunidadT
                            select new JObject(
                                new JProperty("Nom", c.sNombre),
                                new JProperty("Tes", c.sTestimonio),
                                new JProperty("Cal", c.iCalificacion),
                                new JProperty("IDes", c.IdViaje),
                                new JProperty("Des", c.sDestino),
                                new JProperty("FR", c.dtFechaRegistro),
                                new JProperty("Img", String.Format("data:image/gif;base64,{0}", (Convert.ToBase64String(c.ImgDestino))))
                                ));
                }
            }
            catch (Exception x)
            {
                resultado["Exito"] = false;
            }
            return(Content(resultado.ToString()));
        }