public List <Food> GetAllFoodsByCategory(string categoryName) { CategoryDataAccess categoryDataAccess = new CategoryDataAccess(); int categoryId = categoryDataAccess.GetCategoryId(categoryName); this.foodDataAccess = new FoodDataAccess(); return(this.foodDataAccess.GetFoodsByCategoryId(categoryId)); }
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)); }
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)); }
public FoodService() { this.foodDataAccess = new FoodDataAccess(); }