public void DoClose()
        {
            customFood.FoodName        = "" + Food;
            customFood.FoodIngredients = "" + Ingredients;
            customFood.FoodMethod      = "" + Method;

            bool ProteinCorrect = true;
            int  ProteinVal     = 0;

            ProteinCorrect     = int.TryParse(Protein, out ProteinVal);
            customFood.Protein = ProteinVal;

            bool CalorieCorrect = true;
            int  CalorieVal     = 0;

            CalorieCorrect      = int.TryParse(Calorie, out CalorieVal);
            customFood.Calories = CalorieVal;

            bool FatCorrect = true;
            int  FatVal     = 0;

            FatCorrect     = int.TryParse(Fat, out FatVal);
            customFood.Fat = FatVal;

            bool CarbohydrateCorrect = true;
            int  CarbohydrateVal     = 0;

            CarbohydrateCorrect     = int.TryParse(Carbohydrate, out CarbohydrateVal);
            customFood.Carbohydrate = CarbohydrateVal;

            bool FiberCorrect = true;
            int  FiberVal     = 0;

            FiberCorrect     = int.TryParse(Fiber, out FiberVal);
            customFood.Fiber = FiberVal;

            bool CholesterolCorrect = true;
            int  CholesterolVal     = 0;

            CholesterolCorrect     = int.TryParse(Cholesterol, out CholesterolVal);
            customFood.Cholesterol = CholesterolVal;

            bool SodiumCorrect = true;
            int  SodiumVal     = 0;

            SodiumCorrect     = int.TryParse(Sodium, out SodiumVal);
            customFood.Sodium = SodiumVal;

            bool correctValues = (ProteinCorrect && CalorieCorrect && FatCorrect && CarbohydrateCorrect && FiberCorrect && CholesterolCorrect && SodiumCorrect);

            if (correctValues)
            {
                foodDatabase = new FoodsTableDatabaseAzure();
                foodDatabase.InsertFood(customFood);
                Close(this);
            }
        }
Пример #2
0
        private async void startup()
        {
            foodDatabase = new FoodsTableDatabaseAzure();
            var details = await foodDatabase.GetFood();

            foreach (var detail in details)
            {
                Meals.Add(detail);
            }
        }
Пример #3
0
        public async void Init(FoodsTableAutoCompleteResult parameters)
        {
            foodDetails  = parameters;
            foodDatabase = new FoodsTableDatabaseAzure();
            var details = await foodDatabase.GetFood();

            foreach (var detail in details)
            {
                if (detail.Id == foodDetails.Id) //detail.FoodName == "ramen")
                {
                    _foodid      = detail.Id;
                    Food         = detail.FoodName;
                    Calorie      = "" + detail.Calories;
                    Fat          = "" + detail.Fat;
                    Carbohydrate = "" + detail.Carbohydrate;
                    Protein      = "" + detail.Protein;
                    Fiber        = "" + detail.Fiber;
                    Cholesterol  = "" + detail.Cholesterol;
                    Sodium       = "" + detail.Sodium;
                }
            }
        }
        private async Task ShowList()
        {
            string userid = await getuserid();

            string foodid = "";

            Meals.Clear();
            //Meals = new ObservableCollection<FoodsTable>();
            enteredFood  = new FoodEnteredTableDatabaseAzure();
            foodDatabase = new FoodsTableDatabaseAzure();

            var mealdetails = await enteredFood.GetFood();

            foreach (var detail in mealdetails)
            {
                if (detail.UserID == userid)
                {
                    foodid = detail.FoodID;
                    var datas = await foodDatabase.GetFood();

                    foreach (var data in datas)
                    {
                        if (data.Id == foodid)
                        {
                            Meals.Add(data);
                            eatenValue    += data.Calories;
                            Eaten          = "" + eatenValue;
                            remainingValue = remainder();
                            Remaining      = "" + remainingValue;
                        }
                    }
                }
            }

            string exerciseid = "";

            Exercises.Clear();
            //Exercises = new ObservableCollection<ExerciseTable>();
            enteredExer  = new ExerciseEnteredTableDatabaseAzure();
            exerDatabase = new ExerciseTableDatabaseAzure();

            var exerdetails = await enteredExer.GetExercise();

            foreach (var detail in exerdetails)
            {
                if (detail.UserID == userid)
                {
                    exerciseid = detail.ExerciseID;
                    var datas = await exerDatabase.GetExercise();

                    foreach (var data in datas)
                    {
                        if (data.Id == exerciseid)
                        {
                            Exercises.Add(data);
                            burnedValue   += data.Calories;
                            Burned         = "" + burnedValue;
                            remainingValue = remainder();
                            Remaining      = "" + remainingValue;
                        }
                    }
                }
            }
        }