private ProgramViewModel GetProgramViewModel(FitnessProgram program) { var vm = new ProgramViewModel { TemplateViewModel = new TemplateViewModel(program.Template), Id = program.Id, Created = program.Created, ApplicationIdNull = program.ApplicationUserId == null }; var exerciseList = _db.Exercises.ToList(); foreach (WorkoutViewModel workoutViewModel in vm.TemplateViewModel.Workouts) { foreach (MuscleExerciseViewModel muscleExerciseViewModel in workoutViewModel.WorkoutHistoryViewModel .MuscleExerciseViewModels) { muscleExerciseViewModel.ExerciseList = exerciseList .Where(x => x.MuscleType == muscleExerciseViewModel.MuscleType).ToList(); foreach (ExerciseViewModel exerciseViewModel in muscleExerciseViewModel.Exercises) { var linkId = _db.YoutubeVideoQueries.SingleOrDefault(x => x.Query == exerciseViewModel.Name) ?.LinkId; exerciseViewModel.YoutubeVideoId = linkId; } } } return(vm); }
public User RemoveFitnessProgramFromUserPrograms(User user, FitnessProgram fitnessProgram) { user.FitnessPrograms.Remove(fitnessProgram); this.users.SaveChanges(); return(user); }
public User AddFitnessProgramToUserPrograms(User user, FitnessProgram fitnessProgram) { user.FitnessPrograms.Add(fitnessProgram); this.users.SaveChanges(); return(user); }
private void programsGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { program = new FitnessProgram(); programId = Convert.ToInt32(programsGridView.Rows[e.RowIndex].Cells[0].Value.ToString()); program.ProgramName = programsGridView.Rows[e.RowIndex].Cells[1].Value.ToString(); program.Description = programsGridView.Rows[e.RowIndex].Cells[2].Value.ToString(); dataRetriever.setProgramId(programId); dataRetriever.setFitnessProgram(program); }
public IActionResult ProgramJson(TrainerLevelType level = TrainerLevelType.Intermediate, DaysType days = DaysType.FourDays, TemplateType templateType = TemplateType.ABC) { var template = GetTemplate(level, days, templateType.ToString()); var program = new FitnessProgram { Template = template }; return(new JsonResult(GetProgramViewModel(program))); }
public IActionResult GenerateProgram(TrainerLevelType level, DaysType days, string templateType) { var template = GetTemplate(level, days, templateType); var program = new FitnessProgram { Template = template }; HttpContext.Session.Set($"{ProgramSessionPrefix}{program.Created}", program); var vm = GetProgramViewModel(program); return(View("Program", vm)); }
public FitnessProgram Add( string name, string description, Suitable suitableFor, Category category) { var fitnessProgram = new FitnessProgram { Category = category, Name = name, Description = description, SuitableFor = suitableFor }; this.fitnessPrograms.Add(fitnessProgram); this.fitnessPrograms.SaveChanges(); return(fitnessProgram); }