public ActionResult Index() { ProfileViewModel profileViewModel = new ProfileViewModel(); List <CourseProgressViewModel> progressViewModels = new List <CourseProgressViewModel>(); IEnumerable <CourseProgress> courseProgresses = _subscriptions.GetCoursesProgress(User.Identity.Name); var payments = _paymentService.GetByUser(User.Identity.Name); foreach (CourseProgress courseProgress in courseProgresses) { CourseProgressViewModel viewModel = new CourseProgressViewModel(); IPublishedContent course = _coursesContentService.GetCoursePublishedContentById(courseProgress.CourseId); if (course == null) { throw new ArgumentNullException(nameof(courseProgress.CourseId), $"Could not find published content with the specified course Id: {courseProgress.CourseId}"); } viewModel.CourseUrl = course.Url; viewModel.CourseName = course.Name; viewModel.CourseProgress = courseProgress; viewModel.AssessmentUrl = Url.RouteUrl("Assessment", new { courseNiceUrl = course.UrlName }); viewModel.AwaitingPaymentUrl = Url.RouteUrl("AwaitingPayment", new { courseNiceUrl = course.UrlName }); progressViewModels.Add(viewModel); } profileViewModel.ProgressViewModels = progressViewModels; profileViewModel.Certificates = _certificatesService.GetCertificatesForUser(User.Identity.Name); profileViewModel.Orders = _ordersService.GetByUser(User.Identity.Name).Where(x => x.Status == OrderStatusType.Completed); return(View(profileViewModel)); }