Exemple #1
0
        void AddNewRow(int row)
        {
            Label setNo = new Label();

            setNo.FontSize  = 10;
            setNo.TextColor = Color.Gray;
            setNo.Text      = row.ToString();
            setNo.FontSize  = 15;

            setNo.HorizontalOptions = LayoutOptions.Center;
            setNo.VerticalOptions   = LayoutOptions.End;

            Entry repsEntry = new Entry();

            repsEntry.FontSize          = 15;
            repsEntry.TextColor         = Color.FromHex("#1bbc9b");
            repsEntry.HorizontalOptions = LayoutOptions.FillAndExpand;
            repsEntry.VerticalOptions   = LayoutOptions.End;
            repsEntry.Keyboard          = Keyboard.Numeric;

            Entry weightEntry = new Entry();

            weightEntry.FontSize          = 15;
            weightEntry.TextColor         = Color.FromHex("#1bbc9b");
            weightEntry.HorizontalOptions = LayoutOptions.FillAndExpand;
            weightEntry.VerticalOptions   = LayoutOptions.End;
            weightEntry.Keyboard          = Keyboard.Numeric;


            Picker partsPicker = new Picker();

            partsPicker.TextColor         = Color.FromHex("#1bbc9b");
            partsPicker.HorizontalOptions = LayoutOptions.FillAndExpand;
            partsPicker.VerticalOptions   = LayoutOptions.FillAndExpand;

            partsPicker.ItemsSource   = MusclesList;
            partsPicker.SelectedIndex = 0;
            //TimePicker timePicker = new TimePicker();
            //timePicker.TextColor = Color.FromHex("#1bbc9b");
            //timePicker.HorizontalOptions = LayoutOptions.Center;
            //timePicker.VerticalOptions = LayoutOptions.Center;

            Image deleteImage = new Image();

            deleteImage.Source            = "deleteIcon.png";
            deleteImage.HorizontalOptions = LayoutOptions.Center;
            deleteImage.VerticalOptions   = LayoutOptions.Center;

            var tapGestureRecognizer2 = new TapGestureRecognizer();

            tapGestureRecognizer2.Tapped += (s, e) =>
            {
                var img   = (Image)s;
                var rowNo = Grid.GetRow(img);

                DeleteRow(rowNo);
            };
            deleteImage.GestureRecognizers.Add(tapGestureRecognizer2);



            setsGrid.Children.Add(setNo, 0, row);
            setsGrid.Children.Add(repsEntry, 1, row);
            setsGrid.Children.Add(weightEntry, 2, row);
            setsGrid.Children.Add(partsPicker, 3, row);
            setsGrid.Children.Add(deleteImage, 4, row);



            excercise excerciseObj = new excercise();
            //  excerciseObj.exerciseDescription =
        }
Exemple #2
0
        async void SendWorkoutRequest()
        {
            if (setsGrid.Children.ToList().Where(child => Grid.GetRow(child) > 0).Count() == 0)
            {
                await DisplayAlert("Error!", "Please Fill the Fields first", "Ok");

                return;
            }

            Request addWorkoutRequest = new Request();

            workout myWorkout = new workout();

            myWorkout.workOutDes     = workoutNoteTxt.Text;
            myWorkout.workoutTrainee = player.userId;

            excercise        excersise     = new excercise();
            List <excercise> excerciseList = new List <excercise>();

            var allChildren = setsGrid.Children.ToList();

            for (int i = 1; i < rows; i++)
            {
                var childs = allChildren.Where(child => Grid.GetRow(child) == i);
                excersise = new excercise();
                string reps   = "";
                string weight = "";
                string muscle = "";
                foreach (var child in childs)
                {
                    //excerciseDesc = " excercise no " + i + "  is : ";
                    if (child is Entry)
                    {//validations
                        var view = (Entry)child;

                        if (Grid.GetColumn(child) == 1)
                        {
                            reps = string.IsNullOrEmpty(view.Text) ? "" : view.Text;
                        }

                        else if (Grid.GetColumn(child) == 2)
                        {
                            weight = string.IsNullOrEmpty(view.Text) ? "" : view.Text;
                        }
                    }

                    else if (child is Picker)
                    {
                        var view = (Picker)child;

                        muscle = view.SelectedItem.ToString();
                    }
                }
                excersise.excericeId          = i;
                excersise.excericeDescreption = "Excercise " + i + " is ";
                if (!string.IsNullOrEmpty(reps))
                {
                    excersise.excericeDescreption += reps +
                                                     " Reps ";
                }
                if (!string.IsNullOrEmpty(weight))
                {
                    excersise.excericeDescreption += "with " + weight + "kg";
                }

                excersise.excericeDescreption += "  for " + muscle;
                excerciseList.Add(excersise);
            }

            // excersiseList.Remove(excersiseList.Last());
            myWorkout.workoutExcerices = excerciseList;
            string workoutStr = JsonConvert.SerializeObject(myWorkout);

            var response = await addWorkoutRequest.callService("Workout/addworkout", workoutStr, "POST");

            if (response.status == true)
            {
                if (response.content == "STATUS:-3")
                {
                    await DisplayAlert("Error!", "Server Error has occured please try again later!", "Ok");

                    return;
                }

                else if (response.content == "STATUS:-1")
                {
                    await DisplayAlert("Error!", " Invalid Parameters Please enter valid info", "Ok");

                    return;
                }

                await DisplayAlert("Published!", "Your work out has been published successfully", "Ok");

                clearFields();
            }

            else
            {
                await DisplayAlert("Error", "Network Error!", "Ok");
            }
        }
Exemple #3
0
        async void CallSubmitWorkoutService()
        {
            if (setsGrid.Children.ToList().Where(child => Grid.GetRow(child) > 0).Count() == 0)
            {
                await DisplayAlert("Error!", "Please Fill the Fields first", "Ok");

                return;
            }



            Request addWorkoutRequest = new Request();

            workout myWorkout = new workout();

            myWorkout.workOutDes     = workoutNoteTxt.Text;
            myWorkout.workoutTrainee = Playeruser.userId;

            excercise        excersise     = new excercise();
            List <excercise> excerciseList = new List <excercise>();

            var allChildren = setsGrid.Children.ToList();

            for (int i = 1; i < rows; i++)
            {
                var childs = allChildren.Where(child => Grid.GetRow(child) == i);
                excersise = new excercise();
                string activity = "";
                string distance = "";
                string duration = "";
                foreach (var child in childs)
                {
                    if (child is Picker)
                    {
                        var view = (Picker)child;

                        activity = view.SelectedItem.ToString();
                    }



                    else if (child is Entry)
                    {
                        var view = (Entry)child;

                        if (Grid.GetColumn(child) == 2)
                        {
                            distance =
                                string.IsNullOrEmpty(view.Text) ? "": view.Text.ToString();
                        }

                        else if (Grid.GetColumn(child) == 3)
                        {
                            duration = string.IsNullOrEmpty(view.Text) ? "" : view.Text.ToString();
                        }
                    }
                }
                excersise.excericeId          = i;
                excersise.excericeDescreption = "Excercise " + i + " is " + activity;
                if (!string.IsNullOrEmpty(distance))
                {
                    excersise.excericeDescreption +=

                        "  distance of " + distance + "km ";
                }

                if (!string.IsNullOrEmpty(duration))
                {
                    excersise.excericeDescreption += " for " +
                                                     duration + "  minutes";
                }

                excerciseList.Add(excersise);
            }

            myWorkout.workoutExcerices = excerciseList;
            string workoutStr = JsonConvert.SerializeObject(myWorkout);

            var res = await addWorkoutRequest.callService("Workout/addworkout", workoutStr, "POST");

            if (res.status == true)
            {
                if (res.content == "STATUS:-3")
                {
                    await DisplayAlert("Error!", "Server Error has occured please try again later!", "Ok");

                    return;
                }

                else if (res.content == "STATUS:-1")
                {
                    await DisplayAlert("Error!", " Invalid Parameters Please enter valid info", "Ok");

                    return;
                }
                await DisplayAlert("Published!", "Your work out has been published successfully", "Ok");

                clearFields();
            }
            else
            {
                await DisplayAlert("Error", "Network Error!", "Ok");
            }
        }