public async Task <IActionResult> SaveRoutinesForProgram([FromForm] UpdateRoutinesForProgramModel routinesModel)
        {
            var routineIds = JsonConvert.DeserializeObject <List <int> >(routinesModel.SerializedRoutineIds);

            routinesModel.Routines = new List <WorkoutRoutineVM>();
            foreach (var routineId in routineIds)
            {
                var wr = new WorkoutRoutineVM();
                wr.ID           = routineId;
                wr.PlannedDates = null;
                routinesModel.Routines.Add(wr);
            }
            var response = await _workoutTrackerService.SaveRoutinesForProgram(routinesModel);

            return(Json(response));
        }
Beispiel #2
0
        public async Task <WTServiceResponse <string> > SaveRoutinesForProgram(UpdateRoutinesForProgramModel routinesModel)
        {
            // serialize it
            var serializedRoutines = JsonConvert.SerializeObject(routinesModel.Routines);

            var httpClient = await _workoutTrackerHttpClient.GetClient();

            var response = await httpClient.PostAsync($"/api/Programs/user/{UserId()}/program/{routinesModel.ID}/routines",
                                                      new StringContent(serializedRoutines, System.Text.Encoding.Unicode, "application/json"));

            return(HandleApiResponse(response, () =>
            {
                return new WTServiceResponse <string>
                {
                    StatusCode = response.StatusCode,
                    ViewModel = "",
                };
            }));
        }