Example #1
0
        public List <Food> GetAllFoodsByCategory(string categoryName)
        {
            CategoryDataAccess categoryDataAccess = new CategoryDataAccess();
            int categoryId = categoryDataAccess.GetCategoryId(categoryName);

            this.foodDataAccess = new FoodDataAccess();
            return(this.foodDataAccess.GetFoodsByCategoryId(categoryId));
        }
Example #2
0
        public int AddNewFood(string foodName, double foodprice, string categoryName)
        {
            CategoryDataAccess categoryDataAccess = new CategoryDataAccess();
            int categoryId = categoryDataAccess.GetCategoryId(categoryName);

            Food food = new Food()
            {
                FoodName   = foodName,
                FoodPrice  = foodprice,
                CategoryId = categoryId
            };

            this.foodDataAccess = new FoodDataAccess();
            return(this.foodDataAccess.AddFood(food));
        }
Example #3
0
        public int UpdateExistingFood(int foodId, string foodName, double foodprice, string categoryName)
        {
            CategoryDataAccess categoryDataAccess = new CategoryDataAccess();
            int  categoryId = categoryDataAccess.GetCategoryId(categoryName);
            Food food       = new Food()
            {
                FoodId     = foodId,
                FoodName   = foodName,
                FoodPrice  = foodprice,
                CategoryId = categoryId
            };

            this.foodDataAccess = new FoodDataAccess();
            return(this.foodDataAccess.UpdateFood(food));
        }
Example #4
0
 public FoodService()
 {
     this.foodDataAccess = new FoodDataAccess();
 }