public async Task <IActionResult> CreateTrening([FromBody] TrainingDataJson trainingData) { var trainingPlan = await trainingService.CreateTrainingPlan(trainingData); if (trainingPlan == null) { return(new BadRequestResult()); } return(Ok(trainingPlan)); }
public async Task <List <Training> > CreateTrainingPlan(TrainingDataJson trainingData) { var user = await accountRepository.GetCurrentUser(); List <Training> trainingPlanList = new List <Training>(); int breakTime = 0; if (trainingData.Experience == 1) { breakTime = 120; var trainingPlan = await GetReadyTrainingPlan(3, breakTime, user, trainingData.PriorityPart); trainingPlanList = trainingPlan.ToList(); } else if (trainingData.Experience == 2) { breakTime = 90; var trainingPlan = await GetReadyTrainingPlan(4, breakTime, user, trainingData.PriorityPart); trainingPlanList = trainingPlan.ToList(); } else { breakTime = 60; var trainingPlan = await GetReadyTrainingPlan(5, breakTime, user, trainingData.PriorityPart); trainingPlanList = trainingPlan.ToList(); } //if (trainingData.PriorityPart != null) //{ // var result = await AddPriorityExercise(trainingPlanList, trainingData.PriorityPart); // await trainingRepository.Save(); // return result; //} await trainingRepository.Save(); return(trainingPlanList); }