Exemple #1
0
 public bool Remove(IDishContainerDAL dal = null)
 {
     if (!ExistsInDatabase(this.Name, dal))
     {
         return(false);
     }
     return(dishDAL.Remove(this.Name));
 }
Exemple #2
0
 public DishContainer(IDishContainerDAL dal = null)
 {
     if (dal == null)
     {
         this.dishContainerDAL = DishFactory.CreateIDishContainerDal();
     }
     else
     {
         dishContainerDAL = dal;
     }
 }
Exemple #3
0
        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));
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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));
        }
Exemple #6
0
        private bool ExistsInDatabase(string name, IDishContainerDAL dal)
        {
            Dish i = new DishContainer(dal).FindByName(name);

            return(i != null);
        }