public bool Remove(IDishContainerDAL dal = null) { if (!ExistsInDatabase(this.Name, dal)) { return(false); } return(dishDAL.Remove(this.Name)); }
public DishContainer(IDishContainerDAL dal = null) { if (dal == null) { this.dishContainerDAL = DishFactory.CreateIDishContainerDal(); } else { dishContainerDAL = dal; } }
public bool Add(IDishContainerDAL dal = null) { if (ExistsInDatabase(this.Name, dal)) { return(false); } this.Price = (float)Math.Round(this.Price, 2); if (this.Price < 0) { return(false); } return(dishDAL.Add(this.Name, this.Price, this.IngredentDTOs)); }
public List <IngredientDTO> GetIngredientDTOs(IDishContainerDAL dal = null) { List <IngredientDTO> ingredientDTOs = new(); if (this.Ingredients != null) { foreach (Ingredient ingredient in this.Ingredients) { ingredientDTOs.Add(new IngredientDTO { Name = ingredient.Name, Diet = ingredient.Diet }); } } return(ingredientDTOs); }
public bool Update(string oldName, IDishContainerDAL dal = null) { if (ExistsInDatabase(this.Name, dal) && this.Name != oldName) { return(false); } if (!ExistsInDatabase(oldName, dal)) { return(false); } this.Price = (float)Math.Round(this.Price, 2); if (this.Price < 0) { return(false); } return(dishDAL.Update(oldName, this.Name, this.Price, this.IngredentDTOs)); }
private bool ExistsInDatabase(string name, IDishContainerDAL dal) { Dish i = new DishContainer(dal).FindByName(name); return(i != null); }