public static IList <YouCom.DTO.Mensajeria.Imagen.ImagenMensajeNoticiaDTO> getListadoImagenMensajeNoticia()
        {
            IList <YouCom.DTO.Mensajeria.Imagen.ImagenMensajeNoticiaDTO> IImagenMensajeNoticia = new List <YouCom.DTO.Mensajeria.Imagen.ImagenMensajeNoticiaDTO>();

            DataTable pobjDataTable = new DataTable();

            if (YouCom.Mensajeria.DAL.Imagen.ImagenMensajeNoticiaDAL.getListadoImagenMensajeNoticia(ref pobjDataTable))
            {
                foreach (DataRow wobjDataRow in pobjDataTable.Rows)
                {
                    YouCom.DTO.Mensajeria.Imagen.ImagenMensajeNoticiaDTO imagen_mensaje_Noticia = new YouCom.DTO.Mensajeria.Imagen.ImagenMensajeNoticiaDTO();

                    imagen_mensaje_Noticia.IdImagenMensajeNoticia = decimal.Parse(wobjDataRow["IdImagenMensajeNoticia"].ToString());

                    YouCom.DTO.Mensajeria.MensajeNoticiaDTO myMensajeNoticiaDTO = new YouCom.DTO.Mensajeria.MensajeNoticiaDTO();
                    myMensajeNoticiaDTO.IdMensajeNoticia        = decimal.Parse(wobjDataRow["idMensajeNoticia"].ToString());
                    imagen_mensaje_Noticia.TheMensajeNoticiaDTO = myMensajeNoticiaDTO;

                    imagen_mensaje_Noticia.TituloImagenMensajeNoticia   = wobjDataRow["TituloImagenMensajeNoticia"].ToString();
                    imagen_mensaje_Noticia.ThumbailImagenMensajeNoticia = wobjDataRow["ThumbailImagenMensajeNoticia"].ToString();
                    imagen_mensaje_Noticia.GrandeImagenMensajeNoticia   = wobjDataRow["GrandeImagenMensajeNoticia"].ToString();

                    IImagenMensajeNoticia.Add(imagen_mensaje_Noticia);
                }
            }

            return(IImagenMensajeNoticia);
        }
        public static bool ActivaMensajeNoticia(YouCom.DTO.Mensajeria.MensajeNoticiaDTO theMensajeNoticiaDTO)
        {
            bool retorno = false;

            YouCom.Service.BD.SQLHelper wobjSQLHelper = new YouCom.Service.BD.SQLHelper();

            wobjSQLHelper.SetParametro("@usuarioIngreso", SqlDbType.VarChar, 50, theMensajeNoticiaDTO.UsuarioModificacion);
            wobjSQLHelper.SetParametro("@pIdMensajeNoticia", SqlDbType.Decimal, -1, theMensajeNoticiaDTO.IdMensajeNoticia);

            try
            {
                //====================================================================================
                switch (wobjSQLHelper.EjecutarNQ("Activa_MensajeNoticia", "YouCom"))
                {
                case 0:
                    throw new Exception("No se pudo grabar.");

                case -1:
                    throw new Exception("Hubo un error.");

                case -2:
                    throw new Exception("Hubo un error.");
                }
                //====================================================================================
                retorno = true;
            }
            catch (Exception eobjException)
            {
                throw eobjException;
            }
            return(retorno);
        }
        public static bool Update(YouCom.DTO.Mensajeria.MensajeNoticiaDTO myMensajeNoticiaDTO)
        {
            bool retorno = false;

            YouCom.Service.BD.SQLHelper wobjSQLHelper = new YouCom.Service.BD.SQLHelper();

            try
            {
                //Seteo Parámetros.
                //====================================================================================
                wobjSQLHelper.SetParametro("@pIdMensajeNoticia", SqlDbType.Decimal, -1, myMensajeNoticiaDTO.IdMensajeNoticia);
                wobjSQLHelper.SetParametro("@pIdCondominio", SqlDbType.Decimal, -1, myMensajeNoticiaDTO.TheCondominioDTO.IdCondominio);
                wobjSQLHelper.SetParametro("@pIdComunidad", SqlDbType.Decimal, -1, myMensajeNoticiaDTO.TheComunidadDTO.IdComunidad);
                wobjSQLHelper.SetParametro("@pIdPadre", SqlDbType.Decimal, -1, myMensajeNoticiaDTO.IdPadre);
                wobjSQLHelper.SetParametro("@pIdCategoria", SqlDbType.Decimal, -1, myMensajeNoticiaDTO.TheCategoriaDTO.IdCategoria);
                wobjSQLHelper.SetParametro("@pIdFamiliaOrigen", SqlDbType.Decimal, -1, myMensajeNoticiaDTO.TheFamiliaOrigenDTO.IdFamilia > 0 ? myMensajeNoticiaDTO.TheFamiliaOrigenDTO.IdFamilia : System.Data.SqlTypes.SqlDecimal.Null);
                wobjSQLHelper.SetParametro("@pIdFamiliaDestino", SqlDbType.Decimal, -1, myMensajeNoticiaDTO.TheFamiliaDestinoDTO.IdFamilia > 0 ? myMensajeNoticiaDTO.TheFamiliaDestinoDTO.IdFamilia : System.Data.SqlTypes.SqlDecimal.Null);
                wobjSQLHelper.SetParametro("@pFechaMensaje", SqlDbType.DateTime, -1, myMensajeNoticiaDTO.MensajeFecha);
                wobjSQLHelper.SetParametro("@pTituloMensaje", SqlDbType.Text, -1, myMensajeNoticiaDTO.MensajeTitulo);
                wobjSQLHelper.SetParametro("@pDescripcionMensaje", SqlDbType.Text, -1, myMensajeNoticiaDTO.MensajeDescripcion);
                wobjSQLHelper.SetParametro("@pUsuarioModificacion", SqlDbType.VarChar, 20, myMensajeNoticiaDTO.UsuarioModificacion);
                //====================================================================================

                //Ejecuto SP.
                //====================================================================================
                switch (wobjSQLHelper.EjecutarNQ("UPD_MensajeNoticia", "YouCom"))
                {
                case 0:
                    throw new Exception("No se pudo grabar.");

                case -1:
                    throw new Exception("Hubo un error.");

                case -2:
                    throw new Exception("Hubo un error.");
                }
                //====================================================================================

                retorno = true;
            }

            #region Catch

            catch (Exception eobjException)
            {
                throw eobjException;
            }
            #endregion

            return(retorno);
        }
        public static IList <YouCom.DTO.Mensajeria.Video.VideoMensajeNoticiaDTO> getListadoVideoMensajeNoticia()
        {
            Regex YoutubeVideoRegex = new Regex(@"youtu(?:\.be|be\.com)/(?:(.*)v(/|=)|(.*/)?)([a-zA-Z0-9-_]+)", RegexOptions.IgnoreCase);

            IList <YouCom.DTO.Mensajeria.Video.VideoMensajeNoticiaDTO> IVideoMensajeNoticia = new List <YouCom.DTO.Mensajeria.Video.VideoMensajeNoticiaDTO>();

            DataTable pobjDataTable = new DataTable();

            if (YouCom.Mensajeria.DAL.Video.VideoMensajeNoticiaDAL.getListadoVideoMensajeNoticia(ref pobjDataTable))
            {
                foreach (DataRow wobjDataRow in pobjDataTable.Rows)
                {
                    string vCode;
                    string vUrl;

                    Match youtubeMatch = YoutubeVideoRegex.Match(wobjDataRow["UrlVideoMensajePropietario"].ToString());

                    if (youtubeMatch.Success)
                    {
                        YouCom.DTO.Mensajeria.Video.VideoMensajeNoticiaDTO video_mensaje_noticia = new YouCom.DTO.Mensajeria.Video.VideoMensajeNoticiaDTO();

                        video_mensaje_noticia.IdVideoMensajeNoticia = decimal.Parse(wobjDataRow["IdVideoMensajeNoticia"].ToString());

                        YouCom.DTO.Mensajeria.MensajeNoticiaDTO myMensajeNoticiaDTO = new YouCom.DTO.Mensajeria.MensajeNoticiaDTO();
                        myMensajeNoticiaDTO.IdMensajeNoticia       = decimal.Parse(wobjDataRow["idMensajeNoticia"].ToString());
                        video_mensaje_noticia.TheMensajeNoticiaDTO = myMensajeNoticiaDTO;

                        video_mensaje_noticia.TituloVideoMensajeNoticia = wobjDataRow["TituloVideoMensajeNoticia"].ToString();
                        video_mensaje_noticia.UrlVideoMensajeNoticia    = wobjDataRow["UrlVideoMensajeNoticia"].ToString();

                        vCode = video_mensaje_noticia.UrlVideoMensajeNoticia.Substring((video_mensaje_noticia.UrlVideoMensajeNoticia.LastIndexOf("v=") + 2));

                        if (vCode.Contains("&"))
                        {
                            vCode = vCode.Substring(0, vCode.LastIndexOf("&"));
                        }

                        vUrl = @"http://www.youtube.com/v/{0}&autoplay=0\";

                        string video = string.Format(vUrl, vCode);

                        video_mensaje_noticia.UrlWatchVideoMensajeNoticia = video;

                        IVideoMensajeNoticia.Add(video_mensaje_noticia);
                    }
                }
            }

            return(IVideoMensajeNoticia);
        }
        public static bool ValidaEliminacionMensajeNoticia(YouCom.DTO.Mensajeria.MensajeNoticiaDTO theMensajeNoticiaDTO)
        {
            DataTable pobjDataTable = new DataTable();
            bool      retorno       = false;

            if (YouCom.Mensajeria.DAL.MensajeNoticiaDAL.ValidaEliminacionMensajeNoticia(theMensajeNoticiaDTO, ref pobjDataTable))
            {
                foreach (DataRow wobjDataRow in pobjDataTable.Rows)
                {
                    retorno = true;
                }
            }

            return(retorno);
        }
        public static bool Delete(YouCom.DTO.Mensajeria.MensajeNoticiaDTO theMensajeNoticiaDTO)
        {
            bool retorno = false;

            YouCom.Service.BD.SQLHelper wobjSQLHelper = new YouCom.Service.BD.SQLHelper();

            try
            {
                //Seteo Parámetros.
                //====================================================================================
                wobjSQLHelper.SetParametro("@pIdMensajeNoticia", SqlDbType.Decimal, -1, theMensajeNoticiaDTO.IdMensajeNoticia);
                wobjSQLHelper.SetParametro("@pUsuarioModificacion", SqlDbType.VarChar, 20, theMensajeNoticiaDTO.UsuarioModificacion);
                //====================================================================================

                //Ejecuto SP.
                //====================================================================================
                switch (wobjSQLHelper.EjecutarNQ("DEL_MensajeNoticia", "YouCom"))
                {
                case 0:
                    throw new Exception("No se pudo grabar.");

                case -1:
                    throw new Exception("Hubo un error.");

                case -2:
                    throw new Exception("Hubo un error.");
                }
                //====================================================================================

                retorno = true;
            }

            #region Catch

            catch (Exception eobjException)
            {
                throw eobjException;
            }
            #endregion

            return(retorno);
        }
        public static IList <YouCom.DTO.Mensajeria.MensajeNoticiaDTO> getListadoMensajeNoticia()
        {
            IList <YouCom.DTO.Mensajeria.MensajeNoticiaDTO> IMensajeNoticia = new List <YouCom.DTO.Mensajeria.MensajeNoticiaDTO>();

            DataTable pobjDataTable = new DataTable();

            if (YouCom.Mensajeria.DAL.MensajeNoticiaDAL.getListadoMensajeNoticia(ref pobjDataTable))
            {
                foreach (DataRow wobjDataRow in pobjDataTable.Rows)
                {
                    YouCom.DTO.Mensajeria.MensajeNoticiaDTO mensaje_Noticia = new YouCom.DTO.Mensajeria.MensajeNoticiaDTO();

                    mensaje_Noticia.IdMensajeNoticia = decimal.Parse(wobjDataRow["IdMensajeNoticia"].ToString());

                    YouCom.DTO.Seguridad.CondominioDTO myCondominioDTO = new YouCom.DTO.Seguridad.CondominioDTO();
                    myCondominioDTO.IdCondominio     = decimal.Parse(wobjDataRow["idCondominio"].ToString());
                    myCondominioDTO.NombreCondominio = wobjDataRow["nombreCondominio"].ToString();
                    mensaje_Noticia.TheCondominioDTO = myCondominioDTO;

                    YouCom.DTO.Seguridad.ComunidadDTO myComunidadDTO = new YouCom.DTO.Seguridad.ComunidadDTO();
                    myComunidadDTO.IdComunidad      = decimal.Parse(wobjDataRow["idComunidad"].ToString());
                    myComunidadDTO.NombreComunidad  = wobjDataRow["nombreComunidad"].ToString();
                    mensaje_Noticia.TheComunidadDTO = myComunidadDTO;

                    YouCom.DTO.CategoriaDTO myCategoriaDTO = new YouCom.DTO.CategoriaDTO();
                    myCategoriaDTO.IdCategoria      = decimal.Parse(wobjDataRow["idCategoria"].ToString());
                    myCategoriaDTO.NombreCategoria  = wobjDataRow["nombreCategoria"].ToString();
                    mensaje_Noticia.TheCategoriaDTO = myCategoriaDTO;

                    YouCom.DTO.Propietario.FamiliaDTO myFamiliaDTO = new YouCom.DTO.Propietario.FamiliaDTO();

                    if (!string.IsNullOrEmpty(wobjDataRow["idFamiliaOrigen"].ToString()))
                    {
                        myFamiliaDTO.IdFamilia              = decimal.Parse(wobjDataRow["idFamiliaOrigen"].ToString());
                        myFamiliaDTO.NombreFamilia          = wobjDataRow["nombreFamiliaOrigen"].ToString();
                        myFamiliaDTO.ApellidoPaternoFamilia = wobjDataRow["apellidoPaternoFamiliaOrigen"].ToString();
                        myFamiliaDTO.ApellidoMaternoFamilia = wobjDataRow["apellidoMaternoFamiliaOrigen"].ToString();
                        mensaje_Noticia.TheFamiliaOrigenDTO = myFamiliaDTO;
                    }

                    if (!string.IsNullOrEmpty(wobjDataRow["idFamiliaDestino"].ToString()))
                    {
                        myFamiliaDTO.IdFamilia               = decimal.Parse(wobjDataRow["idFamiliaDestino"].ToString());
                        myFamiliaDTO.NombreFamilia           = wobjDataRow["nombreFamiliaDestino"].ToString();
                        myFamiliaDTO.ApellidoPaternoFamilia  = wobjDataRow["apellidoPaternoFamiliaDestino"].ToString();
                        myFamiliaDTO.ApellidoMaternoFamilia  = wobjDataRow["apellidoMaternoFamiliaDestino"].ToString();
                        mensaje_Noticia.TheFamiliaDestinoDTO = myFamiliaDTO;
                    }

                    mensaje_Noticia.MensajeFecha       = DateTime.Parse(wobjDataRow["fechaMensaje"].ToString());
                    mensaje_Noticia.MensajeTitulo      = wobjDataRow["tituloMensaje"].ToString();
                    mensaje_Noticia.MensajeDescripcion = wobjDataRow["descripcionMensaje"].ToString();

                    mensaje_Noticia.IdPadre = !string.IsNullOrEmpty(wobjDataRow["idPadre"].ToString()) ? decimal.Parse(wobjDataRow["idPadre"].ToString()) : 0;

                    mensaje_Noticia.UsuarioIngreso      = wobjDataRow["usuario_ingreso"].ToString();
                    mensaje_Noticia.FechaIngreso        = wobjDataRow["fecha_ingreso"].ToString();
                    mensaje_Noticia.UsuarioModificacion = wobjDataRow["usuario_modificacion"].ToString();
                    mensaje_Noticia.FechaModificacion   = wobjDataRow["fecha_modificacion"].ToString();

                    mensaje_Noticia.Estado = wobjDataRow["estado"].ToString();

                    IMensajeNoticia.Add(mensaje_Noticia);
                }
            }

            return(IMensajeNoticia);
        }