예제 #1
0
        public IActionResult TrainingDetail(string id)
        {
            User user = new User(null, Guid.Empty, null, null, null);
            TrainingViewModel trainingViewModel = new TrainingViewModel();
            Training          training          = ConvertTrainingDTO(user.GetTraining(id));

            if (training.TrainingType == TrainingType.Strength)
            {
                WeightTraining        weightTraining  = ConvertWeightTrainingDTO(user.GetWeightTraining(id));
                List <RoundViewModel> roundViewModels = new List <RoundViewModel>();
                foreach (var round in weightTraining.GetRounds())
                {
                    roundViewModels.Add(ConvertRoundVM(round));
                }
                trainingViewModel.Rounds       = roundViewModels;
                trainingViewModel.Date         = weightTraining.Date;
                trainingViewModel.TrainingID   = weightTraining.TrainingID;
                trainingViewModel.TrainingType = weightTraining.TrainingType;
            }
            else if (training.TrainingType == TrainingType.Cardio)
            {
                CardioTraining cardioTraining = ConvertCardioTrainingDTO(user.GetCardioTraining(id));
                trainingViewModel.Exercise     = ConvertExerciseToVM(cardioTraining.Exercise);
                trainingViewModel.Distance     = cardioTraining.Distance;
                trainingViewModel.Minutes      = cardioTraining.Time.Minutes;
                trainingViewModel.Seconds      = cardioTraining.Time.Seconds;
                trainingViewModel.TrainingID   = cardioTraining.TrainingID;
                trainingViewModel.TrainingType = cardioTraining.TrainingType;
            }
            return(View("../Training/TrainingDetail", trainingViewModel));
        }
예제 #2
0
        private TrainingViewModel ConvertWeightTrainingVM(WeightTraining weightTraining)
        {
            List <RoundViewModel> roundViewModels = new List <RoundViewModel>();

            foreach (var round in weightTraining.GetRounds())
            {
                roundViewModels.Add(ConvertRoundVM(round));
            }
            TrainingViewModel trainingViewModel = new TrainingViewModel
            {
                Date         = weightTraining.Date,
                Rounds       = roundViewModels,
                TrainingID   = weightTraining.TrainingID,
                TrainingType = weightTraining.TrainingType
            };

            return(trainingViewModel);
        }