/*
  * returns course details - Main course page
  * Uses CourseViewModel
  */
 public async Task<ActionResult> Details(Int32? id, String join = null)
 {
     if (id != null)
     {
         Course course = await appContext.Courses.FindAsync(id);
         if (course != null)
         {
             ViewBag.Join = join;
             await CourseHelper.InitializeCourseDetailsComponentsAsync(course, appContext);
             CourseViewModel cVm = new CourseViewModel
             {
                 CourseElement = course,
                 Tags = course.CourseTags
             };
             return View(cVm);
         }
     }
     return RedirectToAction("Index");
 }
 public async Task<ActionResult> Create()
 {
     if (TempData["error"] != null)
         ViewBag.ErrorMessage = TempData["error"];
     CourseViewModel cVm = new CourseViewModel
     {
         CourseElement = TempData["course"] != null ? TempData["course"] as Course : new Course(),
         Tags = await appContext.CourseTags.ToArrayAsync()
     };
     return View(cVm);
 }
 public async Task<ActionResult> Edit(Int32? id)
 {
     if (id != null)
     {
         Course course = await appContext.Courses.FindAsync(id);
         if (course != null)
         {
             CourseViewModel cVm = new CourseViewModel
             {
                 Tags = await appContext.CourseTags.ToArrayAsync(), 
                 CourseElement = course
             };
             return View(cVm);
         }
     }
     return RedirectToAction("Index");
 }