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())); }
public bool bInsertaComunidad(cmComunidad datosCom) { bool bInsertado = false; //using (var contexto = new TravelOKEntities())//local using (var contexto = new TravelOKEntitiesQA())//QA { try { if (contexto.spInsertaComunidad(datosCom.sNombre, datosCom.sTestimonio, datosCom.IdViaje, datosCom.iCalificacion, datosCom.ImgDestino) == -1) { bInsertado = true; } }catch (Exception x) { bInsertado = false; } } return(bInsertado); }