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)); }
private bool ExistsInDatabase(string name, IIngredientContainerDAL containerDAL = null) { Ingredient i = new IngredientContainer(containerDAL).FindByName(name); return(i != null); }