public ActionResult NewEnrollment(CourseEnrollmentViewModel form)
        {
            if (!ModelState.IsValid)
            {
                return View(form);
            }

            var user = _context.Users.Single(u => u.Id == form.UserId);
            var passedDate = form.PassedDate ?? DateTime.Parse("1900-1-1");

            var cohortId = Convert.ToInt32(form.CourseId);
            var course = _context.Courses.Single(c => c.Id == cohortId);

            var newEnrollment = new Enrollment
            {
                ApplicationUser=user,
                PassedDate=passedDate,
                Course = course,
                Note = course.Note,
            };

            _context.Enrollments.Add(newEnrollment);
            _context.SaveChanges();
            var enrollmentId = newEnrollment.Id;

            var enrollment = _context.Enrollments.Include(c=>c.Course).FirstOrDefault(e=>e.Id==enrollmentId);
            EnrollmentServices.CreateScoRecordsForCourse(enrollment, _context);


           

            var id = cohortId;
            return RedirectToAction("Edit", "ManageCourses", new { id });
        }
        public ActionResult NewEnrollment(int id)
        {
            var course = _context.Courses.Include(c => c.CourseTemplate).FirstOrDefault(c => c.Id == id);
            var users = _context.Users.OrderBy(l => l.LastName).ToList().Select(u => new UserLfDto
            {
                Name = u.LfName,
                Id = u.Id
            });

            ViewBag.UserId = new SelectList(users, "Id", "Name");

            if (course != null) ViewBag.Title = "New Enrollment for " + course.CourseTemplate.Title + " - " + course.Id;
            var viewModel = new CourseEnrollmentViewModel
            {
                CourseId = id.ToString(CultureInfo.InvariantCulture)
            };
            return View(viewModel);
        }