Ejemplo n.º 1
0
        public int New_(string p_amount, bool p_isActive, int p_substanceCode)
        {
            IngredientEN ingredientEN = null;
            int          oid;

            //Initialized IngredientEN
            ingredientEN        = new IngredientEN();
            ingredientEN.Amount = p_amount;

            ingredientEN.IsActive = p_isActive;


            if (p_substanceCode != -1)
            {
                // El argumento p_substanceCode -> Property substanceCode es oid = false
                // Lista de oids identifier
                ingredientEN.SubstanceCode            = new ChroniGenNHibernate.EN.Chroni.SubstanceCodeEN();
                ingredientEN.SubstanceCode.Identifier = p_substanceCode;
            }

            //Call to IngredientCAD

            oid = _IIngredientCAD.New_(ingredientEN);
            return(oid);
        }
Ejemplo n.º 2
0
// Modify default (Update all attributes of the class)

        public void ModifyDefault(IngredientEN ingredient)
        {
            try
            {
                SessionInitializeTransaction();
                IngredientEN ingredientEN = (IngredientEN)session.Load(typeof(IngredientEN), ingredient.Identifier);

                ingredientEN.Amount = ingredient.Amount;



                ingredientEN.IsActive = ingredient.IsActive;


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

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


            finally
            {
                SessionClose();
            }
        }
Ejemplo n.º 3
0
        public IngredientEN ReadOIDDefault(int identifier
                                           )
        {
            IngredientEN ingredientEN = null;

            try
            {
                SessionInitializeTransaction();
                ingredientEN = (IngredientEN)session.Get(typeof(IngredientEN), identifier);
                SessionCommit();
            }

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


            finally
            {
                SessionClose();
            }

            return(ingredientEN);
        }
Ejemplo n.º 4
0
        public void Destroy(int identifier
                            )
        {
            try
            {
                SessionInitializeTransaction();
                IngredientEN ingredientEN = (IngredientEN)session.Load(typeof(IngredientEN), identifier);
                session.Delete(ingredientEN);
                SessionCommit();
            }

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


            finally
            {
                SessionClose();
            }
        }
Ejemplo n.º 5
0
        public int New_(IngredientEN ingredient)
        {
            try
            {
                SessionInitializeTransaction();
                if (ingredient.SubstanceCode != null)
                {
                    // Argumento OID y no colección.
                    ingredient.SubstanceCode = (ChroniGenNHibernate.EN.Chroni.SubstanceCodeEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.SubstanceCodeEN), ingredient.SubstanceCode.Identifier);

                    ingredient.SubstanceCode.Ingredient
                    .Add(ingredient);
                }

                session.Save(ingredient);
                SessionCommit();
            }

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


            finally
            {
                SessionClose();
            }

            return(ingredient.Identifier);
        }
Ejemplo n.º 6
0
        public IngredientEN ReadOID(int identifier
                                    )
        {
            IngredientEN ingredientEN = null;

            ingredientEN = _IIngredientCAD.ReadOID(identifier);
            return(ingredientEN);
        }
Ejemplo n.º 7
0
        public void Modify(int p_Ingredient_OID, string p_amount, bool p_isActive)
        {
            IngredientEN ingredientEN = null;

            //Initialized IngredientEN
            ingredientEN            = new IngredientEN();
            ingredientEN.Identifier = p_Ingredient_OID;
            ingredientEN.Amount     = p_amount;
            ingredientEN.IsActive   = p_isActive;
            //Call to IngredientCAD

            _IIngredientCAD.Modify(ingredientEN);
        }