예제 #1
0
        public IActionResult Create(CourseCreateUpdateViewModel course)
        {
            course.Modules     = manyToManyMapper.GetMappedEntities(course, moduleFinder.GetObjects(course.ModuleIds.ToArray()).ToList());
            course.ExamProgram = examprogramService.FindById(course.ExamProgramId);
            course.Mentor      = teacherService.FindById(course.MentorId);
            IActionResult actionResult = View(course);

            if (!ModelState.IsValid || !moduleFinder.AreIdsValid(course.ModuleIds.ToArray()))
            {
                actionResult = View("Error");
            }
            else if (courseService.Insert(course) == 1)
            {
                actionResult = RedirectToAction(nameof(Index));
            }

            return(actionResult);
        }
예제 #2
0
        public IActionResult Create(LearningLineCreateUpdateViewModel learningLine)
        {
            IActionResult actionResult = View(learningLine);

            string[] goals = Array.ConvertAll <int, string>(learningLine.GoalsIds.ToArray(), e => e.ToString());

            learningLine.Goals = mapperService.GetMappedEntities(learningLine, goalFinder.GetObjects(goals));

            if (!ModelState.IsValid || !goalFinder.AreIdsValid(goals))
            {
                actionResult = View("Error");
            }
            else if (learningLineService.Insert(learningLine) == 1)
            {
                actionResult = RedirectToAction(nameof(Index));
            }

            ViewData["Goals"] = goalService.FindAll();

            return(actionResult);
        }
        public IActionResult Create(ModuleCreateUpdateViewModel module)
        {
            IActionResult actionResult = View(module);

            module.Goals   = goalFinder.GetObjects(module.GoalsIds.ToArray()).ToList();
            module.Exams   = examFinder.GetObjects(module.ExamsIds.ToArray()).ToList();
            module.Teacher = teacherService.FindById(module.TeacherId);

            if (!ModelState.IsValid)
            {
                ViewData["g"] = goalService.FindAll();
                ViewData["t"] = teacherService.FindAll();
                ViewData["e"] = examService.FindAll(new string[] { "Module" });
                return(View(module));
            }
            else if (moduleService.Insert(module) == 1)
            {
                actionResult = RedirectToAction(nameof(Index));
            }

            return(actionResult);
        }