Example #1
0
        public async Task <IActionResult> Index(string queryDate)
        {
            await WriteOutIdentityInformation();

            var currentDate = DateTime.Now;

            if (queryDate != null)
            {
                DateTime parsedDate;
                if (DateTime.TryParse(queryDate, out parsedDate))
                {
                    currentDate = parsedDate;
                }
            }
            var UserVM = new UserVM {
                ID = WorkotTrackerHelper.GetUserId(User)
            };
            var sessionRequest = new WorkoutSessionRequest {
                User = UserVM, CurrentDate = currentDate
            };

            var response = await _workoutTrackerService.GetSessionForDay(sessionRequest);

            //set image path relative to api's URL ...
            response.ViewModel.ConcreteExercises.ToList().ForEach(item => item.ImagePath = WorkotTrackerHelper.ApiUrl + item.ImagePath);

            //Get exercises for the user
            var exercisesResposne = await _workoutTrackerService.GetExercisesForUser(UserVM);

            //set image path relative to api's URL ...
            exercisesResposne.ViewModel.ForEach(item => item.ImagePath = WorkotTrackerHelper.ApiUrl + item.ImagePath);
            ViewData["Exercises"] = exercisesResposne.ViewModel;

            //Get routines for the user
            var routineResponse = await _workoutTrackerService.GetRoutinesForUser(UserVM);

            //set image path relative to api's URL ...
            routineResponse.ViewModel.ForEach(item => item.ImagePath = WorkotTrackerHelper.ApiUrl + item.ImagePath);
            routineResponse.ViewModel.ForEach(item => item.Exercises.ToList()
                                              .ForEach(img => img.ImagePath = WorkotTrackerHelper.ApiUrl + img.ImagePath));
            ViewData["Routines"] = routineResponse.ViewModel;

            return(View(response.ViewModel));
        }
Example #2
0
        public async Task <IActionResult> Index()
        {
            await WriteOutIdentityInformation();

            var UserVM = new UserVM {
                ID = WorkotTrackerHelper.GetUserId(User)
            };
            var response = await _workoutTrackerService.GetExercisesForUser(UserVM);

            if (response.ResponseMessage == "AccessDenied" || response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
            {
                return(RedirectToAction("AccessDenied", "Home"));
            }

            //set image path relative to api's URL ...
            response.ViewModel.ForEach(item => item.ImagePath = WorkotTrackerHelper.ApiUrl + item.ImagePath);

            ViewData["Category"] = GetCategorySelectList();

            return(View(response.ViewModel));
        }
Example #3
0
        public async Task <IActionResult> Index()
        {
            var UserVM = new UserVM {
                ID = WorkotTrackerHelper.GetUserId(User)
            };
            var routineResponse = await _workoutTrackerService.GetRoutinesForUser(UserVM);

            //set image path relative to api's URL ...
            routineResponse.ViewModel.ForEach(item => item.ImagePath = WorkotTrackerHelper.ApiUrl + item.ImagePath);
            routineResponse.ViewModel.ForEach(item => item.Exercises.ToList()
                                              .ForEach(img => img.ImagePath = WorkotTrackerHelper.ApiUrl + img.ImagePath));


            //Get exercises for the user
            var exercisesResposne = await _workoutTrackerService.GetExercisesForUser(UserVM);

            //set image path relative to api's URL ...
            exercisesResposne.ViewModel.ForEach(item => item.ImagePath = WorkotTrackerHelper.ApiUrl + item.ImagePath);
            ViewData["Exercises"] = exercisesResposne.ViewModel;


            return(View(routineResponse.ViewModel));
        }