public async Task <IActionResult> ProgressByCoursePost(int courseId, ChartType chartType) { var course = await _context.GetCourseById(courseId); if (course == null) { TempData["Message"] = new SystemMessage(MessageType.Warning, "Fant ikke faget.").GetSystemMessage(); return(RedirectToAction("Time")); } var chartMaker = new ChartMaker(_context); var currentUser = await _userManager.GetUserAsync(HttpContext.User); ViewBag.Courses = await _context.PopulateCourseData(currentUser.Id); ViewBag.chartTitle = chartType.GetDisplayName(); ViewBag.courseTitle = course.Title; switch (chartType) { case ChartType.Progression: ViewBag.Chart = await chartMaker.GenerateCourseChart(course, ChartType.Progression, "Dine arbeidstimer sammenlignet med fagets arbeidsmengde"); break; case ChartType.Workload: ViewBag.Chart = await chartMaker.GenerateCourseChart(course, ChartType.Workload, "Gjennomførte og gjenværende arbeidstimer"); break; } return(View()); }