Ejemplo n.º 1
0
 public bool Remove(IIngredientContainerDAL containerDAL = null)
 {
     if (!ExistsInDatabase(this.Name, containerDAL))
     {
         return(false);
     }
     return(ingredientDAL.Remove(this.Name));
 }
Ejemplo n.º 2
0
 public IngredientContainer(IIngredientContainerDAL dal = null)
 {
     if (dal != null)
     {
         this.ingredientContainerDAL = dal;
     }
     else
     {
         this.ingredientContainerDAL = IngredientFactory.CreateIIngredientContainerDal();
     }
 }
Ejemplo n.º 3
0
        public bool Add(IIngredientContainerDAL containerDAL = null)
        {
            Ingredient i = new IngredientContainer(containerDAL).FindByName(this.Name);

            if (ExistsInDatabase(this.Name, containerDAL))
            {
                return(false);
            }

            if (this.Diet != 0 && this.Diet != 1 && this.Diet != 2)
            {
                return(false);
            }

            return(ingredientDAL.Add(this.Name, this.Diet));
        }
Ejemplo n.º 4
0
        public bool Update(string oldName, IIngredientContainerDAL dal = null)
        {
            if (ExistsInDatabase(this.Name, dal) && this.Name != oldName)
            {
                return(false);
            }

            if (!ExistsInDatabase(oldName, dal))
            {
                return(false);
            }

            if (this.Diet != 0 && this.Diet != 1 && this.Diet != 2)
            {
                return(false);
            }

            return(ingredientDAL.Update(oldName, this.Name, this.Diet));
        }
Ejemplo n.º 5
0
        private bool ExistsInDatabase(string name, IIngredientContainerDAL containerDAL = null)
        {
            Ingredient i = new IngredientContainer(containerDAL).FindByName(name);

            return(i != null);
        }