public AddNewExcercisePage(Int64 WkoutId, int Exertype)
 {
     InitializeComponent();
     _objworkoutTypesViewModel        = new WorkoutTypesViewModel();
     dropdownExerciseType.ItemsSource = _objworkoutTypesViewModel.WorkOutSource;
     Workoutid = WkoutId;
     _objAddExerciseWorkoutRequest  = new AddExerciseWorkoutRequest();
     _objAddExerciseWorkoutResponse = new AddExerciseWorkoutResponse();
     _apiService     = new RestApi();
     _objHeaderModel = new HeaderModel();
     if (Exertype == 1)
     {
         _baseUrl = Settings.Url + Domain.AddExerciseWorkoutApiConstant;
         pageId   = 1;
     }
     if (Exertype == 2)
     {
         _baseUrl = Settings.Url + Domain.AddScheduleExerciseApiConstant;
         pageId   = 2;
     }
     NamesListView.ItemsSource = names;
 }
        private async void BtnSubmitExercise_Clicked(object sender, EventArgs e)
        {
            try
            {
                _objAddExerciseWorkoutRequest.UserId    = Convert.ToInt32(Settings.UserID);
                _objAddExerciseWorkoutRequest.WorkOutId = Convert.ToInt32(Workoutid);
                _objAddExerciseWorkoutRequest.mainList  = new List <MainList>();
                _objHeaderModel.TokenCode = Settings.TokenCode;
                RapList    rl = new RapList();
                MainList   ml = new MainList();
                WeightList wl = new WeightList();
                LevelList  ll = new LevelList();
                TimedList  tl = new TimedList();


                ml.SetsNumber     = NumberofSets;
                ml.ExerciseName   = XFTxtboxExerciseName.Text;
                ml.ExerciseTypeId = WorkOutType;
                if (Settings.WeightName != null)
                {
                    ml.ImperialType = "Weight";
                }
                else
                {
                    ml.ImperialType = "Distance";
                }

                foreach (StackLayout child in GridSets.Children)
                {
                    Entry  entryWeight = (Entry)((Frame)child.Children[0]).Content;
                    string valueWeight = entryWeight.Text;

                    Entry  rep      = (Entry)((Frame)child.Children[3]).Content;
                    string valueRep = rep.Text;
                    if (WorkOutType == Convert.ToInt32(WorkoutSets.Sets_x_Reps_with_weight))
                    {
                        wl.TotalRaps    = Convert.ToInt32(valueRep);
                        wl.TotalWeight  = Convert.ToInt32(valueWeight);
                        wl.ImperialType = Settings.WeightName;
                        ml.weightList.Add(wl);
                        _objAddExerciseWorkoutRequest.mainList.Add(ml);
                    }
                    else if (WorkOutType == Convert.ToInt32(WorkoutSets.Sets_x_Reps_with_Level))
                    {
                        ll.TotalRaps    = Convert.ToInt32(valueRep);
                        ll.TotalWeight  = Convert.ToInt32(valueWeight);
                        ll.ImperialType = Settings.DistanceName;
                        ml.levelList.Add(ll);
                        _objAddExerciseWorkoutRequest.mainList.Add(ml);
                    }

                    else if (WorkOutType == Convert.ToInt32(WorkoutSets.Timed_Sets_seconds))
                    {
                        tl.TimedSet = Convert.ToInt32(valueRep);
                        ml.timedList.Add(tl);
                        _objAddExerciseWorkoutRequest.mainList.Add(ml);
                    }

                    else if (WorkOutType == Convert.ToInt32(WorkoutSets.Sets_x_Reps))
                    {
                        rl.RepsSets = Convert.ToInt32(valueRep);
                        ml.rapList.Add(rl);
                        _objAddExerciseWorkoutRequest.mainList.Add(ml);
                    }

                    else if (WorkOutType == Convert.ToInt32(WorkoutSets.Distance_x_Time))
                    {
                        ml.distance.RepsSetsTime = Convert.ToInt32(valueRep);
                        ml.DistanceInKm          = Convert.ToInt32(valueWeight);
                        _objAddExerciseWorkoutRequest.mainList.Add(ml);
                    }

                    else if (WorkOutType == Convert.ToInt32(WorkoutSets.Free_Text))
                    {
                        ml.textList.Text = (valueWeight);
                        ml.Text          = valueWeight;
                        _objAddExerciseWorkoutRequest.mainList.Add(ml);
                    }
                }

                _objAddExerciseWorkoutResponse = await _apiService.AddExerciseWorkoutPostAsync(new Get_API_Url().CommonBaseApi(_baseUrl), true, _objHeaderModel, _objAddExerciseWorkoutRequest);

                if (_objAddExerciseWorkoutResponse.StatusCode == 200)
                {
                    await Navigation.PopAsync(true);

                    //await Navigation.PopAsync(true);
                    DependencyService.Get <IToast>().Show(_objAddExerciseWorkoutResponse.Message);
                }
                else
                {
                    DependencyService.Get <IToast>().Show(_objAddExerciseWorkoutResponse.Message);
                }

                //if (_objAddWorkoutResponse.StatusCode == 200)
                //{
                //    DependencyService.Get<IToast>().Show(_objAddWorkoutResponse.Message);
                //    WorkoutId = _objAddWorkoutResponse.WorkoutId;
                //}
                //else
                //{
                //    DependencyService.Get<IToast>().Show(_objAddWorkoutResponse.Message);
                //}
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }