private void RegClicked(object sender, EventArgs e)
        {
            var food = new
            {
                Id       = tbId.Text,
                Name     = tbName.Text,
                Quantity = Convert.ToInt32(tbQuantity.Text),
                Price    = Convert.ToInt32(tbPrice.Text),
                RestId   = tbRestId.Text
            };
            var RestResult = RestaurantController.GetRestaurant(tbRestId.Text);

            if (RestResult != null)
            {
                var result = FoodController.AddFood(food);
                if (result)
                {
                    MessageBox.Show("Food Added", "Food Registration", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                else
                {
                    MessageBox.Show("Could not Add Food", "Invalid Registration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Could not Add Restaurant", "Invalid Registration", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private MealController CreateMealController()
        {
            FakeFoodDao    foodDao        = new FakeFoodDao();
            FakeMealDao    mealDao        = new FakeMealDao();
            FoodController foodController = new FoodController(foodDao);

            foodController.AddFood(FOOD);

            MealController mealController = new MealController(mealDao, foodDao);

            return(mealController);
        }
Ejemplo n.º 3
0
        public void Test8(int foodId, string name)
        {
            FoodController foodCont = new FoodController(null, null, context.Object);
            FoodModel      food     = new FoodModel();

            food.FoodId = foodId;
            food.Name   = name;
            OkObjectResult json       = (OkObjectResult)foodCont.AddFood(food);
            FoodModel      returnFood = (FoodModel)json.Value;

            _output.WriteLine($"{returnFood.Name}");
            Assert.Equal(name, returnFood.Name);
        }
Ejemplo n.º 4
0
 private void SaveFood()
 {
     if (ValidateControl())
     {
         Food f = new Food()
         {
             FoodID   = foodController.GetNextId(),
             Name     = txtFoodName.Text,
             Amount   = double.Parse(txtAmount.Text),
             Calories = double.Parse(txtCalories.Text),
             Carbs    = double.Parse(txtCarbs.Text),
             Protein  = double.Parse(txtProtein.Text),
             Fat      = double.Parse(txtFat.Text)
         };
         f.FoodVitamins = GetAllVitamins(f);
         if (foodController.AddFood(f) && foodController.AddFoodVitamin(f.FoodVitamins))
         {
             MessageBoxInformationType(Resources.FoodAddedWithSuccess);
         }
     }
 }