public ActionResult Create(CreateCourseScoViewModel form, HttpPostedFileBase file)
        {
            var filePackage = FileServices.Upload_Backup_and_then_ExtractZip(file, Server, AppConstants.ScoDirectory);
            if (!ModelState.IsValid  || filePackage == null) return View(form);

            var sco = new Sco
            {
                Title = filePackage.Name,
                Directory = filePackage.Directory
            };
            _context.Scos.Add(sco);
            _context.SaveChanges();


            //Add the sco to the new CourseSco and save
            var courseSco = new CourseSco
            {
                Title = sco.Title,
                CourseTemplateId = form.CourseId,
                CatalogueNumber = form.CatalogueNumber,
                RequiredScoId = form.RequiredScoId,
                ScoId = sco.Id
            };
            _context.CourseScos.Add(courseSco);
            _context.SaveChanges();
            return RedirectToAction("Index", new { id = form.CourseId });
        }
 public ActionResult Create(int id)
 {
     var course = _context.CourseTemplates.Find(id);
     ViewBag.ScoId = new SelectList(_context.Scos, "Id", "Title");
     var courseScoViewModel = new CreateCourseScoViewModel
     {
         CourseTitle = course.Title,
         CourseId = id
         //,
         //PreRequisitesList = GetPreRequisitesDropDownList(id)
     };
     return View(courseScoViewModel);
 }
        public ActionResult Create(int id)
        {
            var course = _context.CourseTemplates.Find(id);

            var suppliers = RolesService.GetCourseAuthors(_roleManager, _userManager);
            ViewBag.SupplierId = new SelectList(suppliers, "Id", "LFName", course.SupplierId);
            ViewBag.ScoId = new SelectList(_context.Scos, "Id", "Title");
            var courseScoViewModel = new CreateCourseScoViewModel
            {
                CourseTitle = course.Title,
                CourseId = id
                //,
                //PreRequisitesList = GetPreRequisitesDropDownList(id)
            };
            return View(courseScoViewModel);
        }
        public ActionResult UpdateScoVersion(CreateCourseScoViewModel form, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                FileServices.Upload_Backup_and_then_ExtractZip(file, Server, AppConstants.ScoDirectory);
                return RedirectToAction("Index", new { id = form.CourseId });
            }

            ViewBag.ScoId = new SelectList(_context.Scos, "Id", "Title", form.ScoId);
            return View(form);
        }
        public ActionResult UpdateScoVersion(int id)
        {
            var courseSco = _context.CourseScos.Include(s => s.Sco).FirstOrDefault(s => s.Id == id);
            if (courseSco != null)
            {
                var courseScoViewModel = new CreateCourseScoViewModel
                {
                    CourseId = courseSco.CourseTemplateId,
                    ScoId = courseSco.ScoId,
                    Directory = courseSco.Sco.Directory,
                    ScoTitle = courseSco.Sco.Title
                };


                return View(courseScoViewModel);
            }
            return null;
        }
        public async Task<ActionResult> Associate(CreateCourseScoViewModel form)
        {
            if (ModelState.IsValid)
            {
                var sco = _context.Scos.Find(form.ScoId);
                var scoTitle = sco.Title;

                var courseSco = new CourseSco
                {
                    Title = scoTitle,
                    CourseTemplateId = form.CourseId,
                    ScoId = form.ScoId,
                    CatalogueNumber = form.CatalogueNumber,
                    RequiredScoId = form.RequiredScoId
                };
                _context.CourseScos.Add(courseSco);
                await _context.SaveChangesAsync();
                return RedirectToAction("Index", new { id = form.CourseId });
            }

            ViewBag.ScoId = new SelectList(_context.Scos, "Id", "Title", form.ScoId);
            return View(form);
        }