示例#1
0
        public void QuitarPack(int p_Variable_OID, System.Collections.Generic.IList <int> p_pack_OIDs)
        {
            try
            {
                SesssionInitializeTransaction();
                PersonalHomeGenNHibernate.EN.PersonalHome.VariableEN variableEN = null;
                variableEN = (VariableEN)session.Load(typeof(VariableEN), p_Variable_OID);

                EN.PersonalHome.PackEN packEN = null;
                if (variableEN.Pack != null)
                {
                    foreach (int item in p_pack_OIDs)
                    {
                        packEN = (PackEN)session.Load(typeof(PackEN), item);
                        if (variableEN.Pack.Contains(packEN) == true)
                        {
                            variableEN.Pack.Remove(packEN);
                        }
                        else
                        {
                            throw new ModelException("The identifier " + item + " in p_pack_OIDs you are trying to unrelationer, doesn't exist in VariableEN");
                        }
                    }
                }

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

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


            finally
            {
                SessionClose();
            }
        }
示例#2
0
        public void AsignarPack(int p_Variable_OID, System.Collections.Generic.IList <int> p_pack_OIDs)
        {
            PersonalHomeGenNHibernate.EN.PersonalHome.VariableEN variableEN = null;
            try
            {
                SesssionInitializeTransaction();
                variableEN = (VariableEN)session.Load(typeof(VariableEN), p_Variable_OID);
                PersonalHomeGenNHibernate.EN.PersonalHome.PackEN packEN = null;
                if (variableEN.Pack == null)
                {
                    variableEN.Pack = new System.Collections.Generic.List <EN.PersonalHome.PackEN>();
                }

                foreach (int item in p_pack_OIDs)
                {
                    packEN = new EN.PersonalHome.PackEN();
                    packEN = (EN.PersonalHome.PackEN)session.Load(typeof(EN.PersonalHome.PackEN), item);
                    variableEN.Pack.Add(packEN);
                }


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

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


            finally
            {
                SessionClose();
            }
        }