public IActionResult Index(int id) { var taskData = _context.TaskVariants .Where(taskVariant => taskVariant.Id == id) .Select(taskVariant => new { CourseId = taskVariant.TaskGroup.CourseId, CourseName = taskVariant.TaskGroup.Course.Name, TaskGroupId = taskVariant.TaskGroupId, TaskGroupName = taskVariant.TaskGroup.Name, TaskVariantId = taskVariant.Id, TaskVariantName = taskVariant.Name }).FirstOrDefault(); try { var assignments = _assignmentLogic.GetAssignmentsForTaskVariant(id); return(View(new IndexViewModel() { CourseId = taskData.CourseId, CourseName = taskData.CourseName, TaskGroupId = taskData.TaskGroupId, TaskGroupName = taskData.TaskGroupName, TaskVariantId = taskData.TaskVariantId, TaskVariantName = taskData.TaskVariantName, Assignments = assignments, IsCourseTeacher = KaCakeUtils.IsCourseTeacher(_context, taskData.CourseId, _userManager.GetUserId(HttpContext.User)) })); } catch (NotFoundException) { return(NotFound()); } }