public async Task <IActionResult> SaveProgram([FromForm] WorkoutProgramVM program) { var routines = JsonConvert.DeserializeObject <List <WorkoutRoutineVM> >(program.RoutinesSerialized); program.WorkoutRoutines = routines; if (program.Image != null) { program.ImagePath = program.Image.FileName; using (var fileStream = program.Image.OpenReadStream()) { using (var ms = new MemoryStream()) { fileStream.CopyTo(ms); program.ImageBytes = ms.ToArray(); } } } var response = await _workoutTrackerService.SaveProgram(program); return(Json(response)); }