public JsonResult Index(CourseOfferingViewModel viewModel)
        {
            try
            {
                // Populate
                viewModel = new CourseOfferingViewModelFactory(viewModel, _courseService).GetViewModel();

                // Validate
                if (!ModelState.IsValid)
                    return Json(new {status = "error", message = "Validation Errors"});

                // Bind
                var courseOffering = new CourseOffering
                {
                    CourseId = viewModel.SelectedCourse,
                    Semester = viewModel.Semester.GetValueOrDefault(),
                    Year = viewModel.SelectedYear
                };

                // Save
                _courseService.AddCourseOffering(courseOffering);

                // Respond
                return Json(new {status = "success", message = "Course Offering Added"});
            }
            catch (CourseOfferingExistsException)
            {
                return Json(new {status = "error", message = "Course Offering already exists"});
            }
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="CourseOfferingViewModelFactory" /> class.
 /// </summary>
 /// <param name="viewModel">The view model.</param>
 /// <param name="courseService">The course service.</param>
 public CourseOfferingViewModelFactory(CourseOfferingViewModel viewModel, ICourseService courseService)
 {
     _viewModel = viewModel;
     _courseService = courseService;
 }