Example #1
0
        public void BorrarReportadores(int p_comentario, System.Collections.Generic.IList <int> p_superusuario)
        {
            try
            {
                SessionInitializeTransaction();
                NuevoInmueblateGenNHibernate.EN.RedSocial.ComentarioEN comentarioEN = null;
                comentarioEN = (ComentarioEN)session.Load(typeof(ComentarioEN), p_comentario);

                NuevoInmueblateGenNHibernate.EN.RedSocial.SuperUsuarioEN reportadoresENAux = null;
                if (comentarioEN.Reportadores != null)
                {
                    foreach (int item in p_superusuario)
                    {
                        reportadoresENAux = (NuevoInmueblateGenNHibernate.EN.RedSocial.SuperUsuarioEN)session.Load(typeof(NuevoInmueblateGenNHibernate.EN.RedSocial.SuperUsuarioEN), item);
                        if (comentarioEN.Reportadores.Contains(reportadoresENAux) == true)
                        {
                            comentarioEN.Reportadores.Remove(reportadoresENAux);
                            reportadoresENAux.ComentariosReportados.Remove(comentarioEN);
                        }
                        else
                        {
                            throw new ModelException("The identifier " + item + " in p_superusuario you are trying to unrelationer, doesn't exist in ComentarioEN");
                        }
                    }
                }

                session.Update(comentarioEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is NuevoInmueblateGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new NuevoInmueblateGenNHibernate.Exceptions.DataLayerException("Error in ComentarioCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Example #2
0
        public void BorrarElementosMultimedia(int p_comentario, System.Collections.Generic.IList <int> p_elementomultimedia)
        {
            try
            {
                SessionInitializeTransaction();
                NuevoInmueblateGenNHibernate.EN.RedSocial.ComentarioEN comentarioEN = null;
                comentarioEN = (ComentarioEN)session.Load(typeof(ComentarioEN), p_comentario);

                NuevoInmueblateGenNHibernate.EN.RedSocial.ElementoMultimediaEN elementosMultimediaENAux = null;
                if (comentarioEN.ElementosMultimedia != null)
                {
                    foreach (int item in p_elementomultimedia)
                    {
                        elementosMultimediaENAux = (NuevoInmueblateGenNHibernate.EN.RedSocial.ElementoMultimediaEN)session.Load(typeof(NuevoInmueblateGenNHibernate.EN.RedSocial.ElementoMultimediaEN), item);
                        if (comentarioEN.ElementosMultimedia.Contains(elementosMultimediaENAux) == true)
                        {
                            comentarioEN.ElementosMultimedia.Remove(elementosMultimediaENAux);
                            elementosMultimediaENAux.AparicionComentarios.Remove(comentarioEN);
                        }
                        else
                        {
                            throw new ModelException("The identifier " + item + " in p_elementomultimedia you are trying to unrelationer, doesn't exist in ComentarioEN");
                        }
                    }
                }

                session.Update(comentarioEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is NuevoInmueblateGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new NuevoInmueblateGenNHibernate.Exceptions.DataLayerException("Error in ComentarioCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Example #3
0
        public void AnyadirReportador(int p_comentario, System.Collections.Generic.IList <int> p_superusuario)
        {
            NuevoInmueblateGenNHibernate.EN.RedSocial.ComentarioEN comentarioEN = null;
            try
            {
                SessionInitializeTransaction();
                comentarioEN = (ComentarioEN)session.Load(typeof(ComentarioEN), p_comentario);
                NuevoInmueblateGenNHibernate.EN.RedSocial.SuperUsuarioEN reportadoresENAux = null;
                if (comentarioEN.Reportadores == null)
                {
                    comentarioEN.Reportadores = new System.Collections.Generic.List <NuevoInmueblateGenNHibernate.EN.RedSocial.SuperUsuarioEN>();
                }

                foreach (int item in p_superusuario)
                {
                    reportadoresENAux = new NuevoInmueblateGenNHibernate.EN.RedSocial.SuperUsuarioEN();
                    reportadoresENAux = (NuevoInmueblateGenNHibernate.EN.RedSocial.SuperUsuarioEN)session.Load(typeof(NuevoInmueblateGenNHibernate.EN.RedSocial.SuperUsuarioEN), item);
                    reportadoresENAux.ComentariosReportados.Add(comentarioEN);

                    comentarioEN.Reportadores.Add(reportadoresENAux);
                }


                session.Update(comentarioEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is NuevoInmueblateGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new NuevoInmueblateGenNHibernate.Exceptions.DataLayerException("Error in ComentarioCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Example #4
0
        public void AnyadirElementosMultimedia(int p_comentario, System.Collections.Generic.IList <int> p_elementomultimedia)
        {
            NuevoInmueblateGenNHibernate.EN.RedSocial.ComentarioEN comentarioEN = null;
            try
            {
                SessionInitializeTransaction();
                comentarioEN = (ComentarioEN)session.Load(typeof(ComentarioEN), p_comentario);
                NuevoInmueblateGenNHibernate.EN.RedSocial.ElementoMultimediaEN elementosMultimediaENAux = null;
                if (comentarioEN.ElementosMultimedia == null)
                {
                    comentarioEN.ElementosMultimedia = new System.Collections.Generic.List <NuevoInmueblateGenNHibernate.EN.RedSocial.ElementoMultimediaEN>();
                }

                foreach (int item in p_elementomultimedia)
                {
                    elementosMultimediaENAux = new NuevoInmueblateGenNHibernate.EN.RedSocial.ElementoMultimediaEN();
                    elementosMultimediaENAux = (NuevoInmueblateGenNHibernate.EN.RedSocial.ElementoMultimediaEN)session.Load(typeof(NuevoInmueblateGenNHibernate.EN.RedSocial.ElementoMultimediaEN), item);
                    elementosMultimediaENAux.AparicionComentarios.Add(comentarioEN);

                    comentarioEN.ElementosMultimedia.Add(elementosMultimediaENAux);
                }


                session.Update(comentarioEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is NuevoInmueblateGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new NuevoInmueblateGenNHibernate.Exceptions.DataLayerException("Error in ComentarioCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Example #5
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            ComentarioEN t = obj as ComentarioEN;

            if (t == null)
            {
                return(false);
            }
            if (Id.Equals(t.Id))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #6
0
 public ComentarioEN(ComentarioEN comentario)
 {
     this.init(Id, comentario.Cuerpo, comentario.PendienteModeracion, comentario.FechaPublicacion, comentario.Creador, comentario.Reportadores, comentario.Entrada, comentario.ElementosMultimedia);
 }