Ejemplo n.º 1
0
        public ActionResult NewCourse(CreateCourseViewModel model)
        {
            ActionResult result;

            //Validate the model before proceeding
            if (!ModelState.IsValid)
            {
                //not valid
                result = View("Dashboard", model);
            }
            else
            {
                //valid
                Course course = new Course
                {//-----------------------------NEEDS TO BE CHANGED
                    CourseName  = model.Name,
                    Description = model.Description,
                    Difficulty  = (int)model.DifficultyLevel,
                    TeacherId   = CurrentUser.UserId,
                    CostUSD     = model.Cost
                };

                course       = _db.CreateCourse(course);
                course       = _db.GetCourseId(course.CourseName);
                course.Image = _db.CreateFileForTeacherCourse(model.PostedFile, course.CourseId);

                _db.UpdateCourseWithFileId(course.CourseId);
                result = RedirectToAction("Index", "Home");
            }
            return(result);
        }
Ejemplo n.º 2
0
        public ActionResult _CreateCourse()
        {
            CreateCourseViewModel model = new CreateCourseViewModel();

            if (!IsTeacher)
            {
                RedirectToAction("NotAuth", "Home");
            }

            return(View("_CreateCourse", model));
        }