Esempio n. 1
0
        public IActionResult Add()
        {
            var vm = new AddQuesAnswerViewModel();

            // Get the list of courses for the dropdown
            vm.Courses       = context.ReadAllCourses().ToList();
            vm.LearnOutcomes = context.ReadAllOutcomes().ToList();

            return(View(vm));
        }
Esempio n. 2
0
        public IActionResult Add(AddQuesAnswerViewModel vm)
        {
            //Reinitialize the options for the select lists
            vm.Courses       = context.ReadAllCourses().ToList();
            vm.LearnOutcomes = context.ReadAllOutcomes().ToList();

            //TODO: Fix the value cannot be null problem
            if (!ModelState.IsValid)
            {
                return(View("Add", vm));
            }

            QuesAnswer Qa = new QuesAnswer
            {
                Question     = vm.Question,
                Answer       = vm.Answer,
                Course       = context.ReadCourse(vm.CourseId),
                LearnOutcome = context.ReadOutcome(vm.LearnOutcomeId)
            };

            context.createQuesetion(Qa);
            return(RedirectToAction("Index"));
        }