Example #1
0
        //Add method to generate PDF report
        //Add unit testing class


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                var foodItemManager = new FoodItemManager();
                foodItemManager.Calculator.SumMacros(foodItemManager.DbFoodItems);
                if (foodItemManager.Calculator.TotalCalories > 0)
                {
                    foodItemManager.Calculator.DetermineRatio();
                }
                DisplayData(foodItemManager.Calculator, foodItemManager.DbFoodItems);
            }

            errorLabel.Text = "";
        }
Example #2
0
        protected void addButton_Click(object sender, EventArgs e)
        {
            var foodItemManager = new FoodItemManager();

            if (!foodItemManager.ValidateUserInput(foodItemManager.NewFoodItem,
                                                   newNameTextBox.Text,
                                                   newCaloriesTextBox.Text,
                                                   newProteinsTextBox.Text,
                                                   newCarbsTextBox.Text,
                                                   newFatsTextBox.Text))
            {
                foodItemManager.Calculator.SumMacros(foodItemManager.DbFoodItems);
                foodItemManager.Calculator.DetermineRatio();
                DisplayData(foodItemManager.Calculator, foodItemManager.DbFoodItems);
                errorLabel.Text = "You must use a valid name and number!";
                return;
            }

            foodItemManager.UpdateDatabase();
            foodItemManager.Calculator.SumMacros(foodItemManager.DbFoodItems);
            foodItemManager.Calculator.DetermineRatio();
            DisplayData(foodItemManager.Calculator, foodItemManager.DbFoodItems);
        }