public UpdateActualExercisePage(EditExercise ObjEditExercise) { InitializeComponent(); _objworkoutTypesViewModel = new WorkoutTypesViewModel(); dropdownExerciseType.ItemsSource = _objworkoutTypesViewModel.WorkOutSource; _objEditExercise = new EditExercise(); _objEditExercise = ObjEditExercise; WorkOutType = _objEditExercise.ExerciseTypeId; NumberofSets = _objEditExercise.SetsNumber; Workoutid = Convert.ToInt32(_objEditExercise.WorkOutId); _apiService = new RestApi(); _objHeaderModel = new HeaderModel(); _baseUrl = Settings.Url + Domain.AddActualExerciseApiConstant; _objAddActualExerciseRequest = new AddActualExerciseRequest(); _objAddActualExerciseResponse = new AddActualExerciseResponse(); LoadPageView(); }
//private void EntryNoOfSets_Unfocused(object sender, FocusEventArgs e) //{ // NumberofSets = Convert.ToInt32(EntryNoOfSets.Text); // if (WorkOutType > 0) // { // GridSets.Children.Clear(); // } // LoadPageView(); //} private async void BtnSubmitExercise_Clicked(object sender, EventArgs e) { try { _objAddActualExerciseRequest.UserId = Convert.ToInt32(Settings.UserID); _objAddActualExerciseRequest.WorkOutId = Workoutid; _objAddActualExerciseRequest.UpdateList = new List <UpdateList>(); _objHeaderModel.TokenCode = Settings.TokenCode; ActualRapList rl = new ActualRapList(); UpdateList ml = new UpdateList(); ActualWeightList wl = new ActualWeightList(); LevList ll = new LevList(); TimList tl = new TimList(); DisList dl = new DisList(); TextListOfActual atl = new TextListOfActual(); ml.SetsNumber = Convert.ToInt32(EntryNoOfSets.Text); ml.ExerciseName = XFTxtboxExerciseName.Text; ml.ExerciseTypeId = Convert.ToInt32(WorkOutType); if (wl != null) { ml.ImperialType = Settings.WeightName; } else { ml.ImperialType = Settings.DistanceName; } 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.ToDecimal(valueWeight); wl.ImperialType = Settings.WeightName; ml.weightList.Add(wl); _objAddActualExerciseRequest.UpdateList.Add(ml); } else if (WorkOutType == Convert.ToInt32(WorkoutSets.Sets_x_Reps_with_Level)) { ll.TotalRaps = Convert.ToInt32(valueRep); ll.TotalWeight = Convert.ToDecimal(valueWeight); ll.ImperialType = Settings.WeightName; ml.levList.Add(ll); _objAddActualExerciseRequest.UpdateList.Add(ml); } else if (WorkOutType == Convert.ToInt32(WorkoutSets.Timed_Sets_seconds)) { tl.TimedSet = Convert.ToInt32(valueRep); ml.timList.Add(tl); _objAddActualExerciseRequest.UpdateList.Add(ml); } else if (WorkOutType == Convert.ToInt32(WorkoutSets.Sets_x_Reps)) { rl.RepsSets = Convert.ToInt32(valueRep); ml.rapList.Add(rl); _objAddActualExerciseRequest.UpdateList.Add(ml); } else if (WorkOutType == Convert.ToInt32(WorkoutSets.Distance_x_Time)) { dl.RepsSetsTime = Convert.ToInt32(valueRep); ml.DistanceInKm = Convert.ToDouble(valueWeight); ml.disList.Add(dl); _objAddActualExerciseRequest.UpdateList.Add(ml); } else if (WorkOutType == Convert.ToInt32(WorkoutSets.Free_Text)) { atl.Text = (valueRep); ml.Text = valueRep; ml.textListOfActual.Add(atl); _objAddActualExerciseRequest.UpdateList.Add(ml); } } _objAddActualExerciseResponse = await _apiService.AddActualExerciseAsync(new Get_API_Url().CommonBaseApi(_baseUrl), true, _objHeaderModel, _objAddActualExerciseRequest); if (_objAddActualExerciseResponse.Response.StatusCode == 200) { DependencyService.Get <IToast>().Show(_objAddActualExerciseResponse.Response.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; } }