public bool Remove(IIngredientContainerDAL containerDAL = null) { if (!ExistsInDatabase(this.Name, containerDAL)) { return(false); } return(ingredientDAL.Remove(this.Name)); }
public IngredientContainer(IIngredientContainerDAL dal = null) { if (dal != null) { this.ingredientContainerDAL = dal; } else { this.ingredientContainerDAL = IngredientFactory.CreateIIngredientContainerDal(); } }
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)); }
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)); }
private bool ExistsInDatabase(string name, IIngredientContainerDAL containerDAL = null) { Ingredient i = new IngredientContainer(containerDAL).FindByName(name); return(i != null); }