public void Eliminar_fav(int p_Registrado_OID, System.Collections.Generic.IList <int> p_a_favorito_OIDs)
        {
            try
            {
                SessionInitializeTransaction();
                DSM1GenNHibernate.EN.DSM1.RegistradoEN registradoEN = null;
                registradoEN = (RegistradoEN)session.Load(typeof(RegistradoEN), p_Registrado_OID);

                DSM1GenNHibernate.EN.DSM1.ArticuloEN a_favoritoENAux = null;
                if (registradoEN.A_favorito != null)
                {
                    foreach (int item in p_a_favorito_OIDs)
                    {
                        a_favoritoENAux = (DSM1GenNHibernate.EN.DSM1.ArticuloEN)session.Load(typeof(DSM1GenNHibernate.EN.DSM1.ArticuloEN), item);
                        if (registradoEN.A_favorito.Contains(a_favoritoENAux) == true)
                        {
                            registradoEN.A_favorito.Remove(a_favoritoENAux);
                            a_favoritoENAux.Registrado.Remove(registradoEN);
                        }
                        else
                        {
                            throw new ModelException("The identifier " + item + " in p_a_favorito_OIDs you are trying to unrelationer, doesn't exist in RegistradoEN");
                        }
                    }
                }

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

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


            finally
            {
                SessionClose();
            }
        }
        public void Añadir_fav(int p_Registrado_OID, System.Collections.Generic.IList <int> p_a_favorito_OIDs)
        {
            DSM1GenNHibernate.EN.DSM1.RegistradoEN registradoEN = null;
            try
            {
                SessionInitializeTransaction();
                registradoEN = (RegistradoEN)session.Load(typeof(RegistradoEN), p_Registrado_OID);
                DSM1GenNHibernate.EN.DSM1.ArticuloEN a_favoritoENAux = null;
                if (registradoEN.A_favorito == null)
                {
                    registradoEN.A_favorito = new System.Collections.Generic.List <DSM1GenNHibernate.EN.DSM1.ArticuloEN>();
                }

                foreach (int item in p_a_favorito_OIDs)
                {
                    a_favoritoENAux = new DSM1GenNHibernate.EN.DSM1.ArticuloEN();
                    a_favoritoENAux = (DSM1GenNHibernate.EN.DSM1.ArticuloEN)session.Load(typeof(DSM1GenNHibernate.EN.DSM1.ArticuloEN), item);
                    a_favoritoENAux.Registrado.Add(registradoEN);

                    registradoEN.A_favorito.Add(a_favoritoENAux);
                }


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

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


            finally
            {
                SessionClose();
            }
        }
Exemple #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);
            }
        }
Exemple #4
0
 public ArticuloEN(ArticuloEN articulo)
 {
     this.init(Id, articulo.Nombre, articulo.Precio, articulo.Categoria, articulo.Valoracion, articulo.LineaPedido, articulo.Puja, articulo.Registrado, articulo.Descripcion, articulo.Stock, articulo.Imagen, articulo.Img_3d, articulo.Videojuego);
 }