public IActionResult OnPost(int? ClientId) { if (!ClientId.HasValue) { return RedirectToPage("/Index"); } BFS requestDirector = new BFS(); Client = requestDirector.GetClientById(ClientId.Value); ActiveWorkoutPlans = requestDirector.GetActiveWorkoutPlansByClientId(Client.ClientId); InactiveWorkoutPlans = requestDirector.GetInactiveWorkoutPlansByClientId(Client.ClientId); if (Submit.Equals("SubmitStartWorkout")) { Workout inProgressWorkout = requestDirector.GetInProgressWorkoutByClientId(Client.ClientId); if (inProgressWorkout.WorkoutName == null) { WorkoutPlan workoutPlan = requestDirector.GetWorkoutPlanById(WorkoutPlanId); int workoutId = requestDirector.StartWorkout(workoutPlan); } else { ErrorString = "You already have a workout in progress"; } } return Page(); }