Beispiel #1
0
        public void Eliminarcomentario(int p_articulo_OID, System.Collections.Generic.IList <int> p_comentario_OIDs)
        {
            try
            {
                SessionInitializeTransaction();
                SMPGenNHibernate.EN.SMP.ArticuloEN articuloEN = null;
                articuloEN = (ArticuloEN)session.Load(typeof(ArticuloEN), p_articulo_OID);

                SMPGenNHibernate.EN.SMP.ComentarioEN comentarioENAux = null;
                if (articuloEN.Comentario != null)
                {
                    foreach (int item in p_comentario_OIDs)
                    {
                        comentarioENAux = (SMPGenNHibernate.EN.SMP.ComentarioEN)session.Load(typeof(SMPGenNHibernate.EN.SMP.ComentarioEN), item);
                        if (articuloEN.Comentario.Contains(comentarioENAux) == true)
                        {
                            articuloEN.Comentario.Remove(comentarioENAux);
                            comentarioENAux.Articulo = null;
                        }
                        else
                        {
                            throw new ModelException("The identifier " + item + " in p_comentario_OIDs you are trying to unrelationer, doesn't exist in ArticuloEN");
                        }
                    }
                }

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

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


            finally
            {
                SessionClose();
            }
        }
Beispiel #2
0
        public void Addcomentario(int p_articulo_OID, System.Collections.Generic.IList <int> p_comentario_OIDs)
        {
            SMPGenNHibernate.EN.SMP.ArticuloEN articuloEN = null;
            try
            {
                SessionInitializeTransaction();
                articuloEN = (ArticuloEN)session.Load(typeof(ArticuloEN), p_articulo_OID);
                SMPGenNHibernate.EN.SMP.ComentarioEN comentarioENAux = null;
                if (articuloEN.Comentario == null)
                {
                    articuloEN.Comentario = new System.Collections.Generic.List <SMPGenNHibernate.EN.SMP.ComentarioEN>();
                }

                foreach (int item in p_comentario_OIDs)
                {
                    comentarioENAux          = new SMPGenNHibernate.EN.SMP.ComentarioEN();
                    comentarioENAux          = (SMPGenNHibernate.EN.SMP.ComentarioEN)session.Load(typeof(SMPGenNHibernate.EN.SMP.ComentarioEN), item);
                    comentarioENAux.Articulo = articuloEN;

                    articuloEN.Comentario.Add(comentarioENAux);
                }


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

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


            finally
            {
                SessionClose();
            }
        }
Beispiel #3
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            ArticuloEN t = obj as ArticuloEN;

            if (t == null)
            {
                return(false);
            }
            if (Id.Equals(t.Id))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
 public ArticuloEN(ArticuloEN articulo)
 {
     this.init(Id, articulo.Nombre, articulo.Precio, articulo.Descripcion, articulo.Imagen, articulo.Comentario, articulo.Valor, articulo.Stock, articulo.Oferta, articulo.Descriplarga, articulo.Imagran);
 }