コード例 #1
0
        /// <summary>
        /// Deleting an outcome
        /// </summary>
        /// <param name="id">Id for a outcome</param>
        /// <returns></returns>
        public void DeleteOutcome(int id)
        {
            LearnOutcome learnOutcome = _db.LearnOutcome.Find(id);

            _db.LearnOutcome.Remove(learnOutcome);
            _db.SaveChanges();
        }
コード例 #2
0
        /// <summary>
        /// Add learnOutcome to a course
        /// </summary>
        ///
        /// <returns></returns>
        public void AddLOToACourse(LearnOutcome lo, Course course)
        {
            Course newCourse = ReadCourse(course.Id);

            newCourse.LearnOutcomes.Add(lo);

            _db.Courses.Update(newCourse);
            _db.SaveChanges();
        }
コード例 #3
0
        /// <summary>
        /// IAction method for returning details of a learningOutcome
        /// </summary>
        /// <param name="id">Id for a learningOutcome</param>
        /// <returns></returns>
        public IActionResult Details(int id)
        {
            LearnOutcome learn = context.ReadOutcome(id);

            if (learn == null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(learn));
        }
コード例 #4
0
        /// <summary>
        /// IAction method for returning a deletion view
        /// </summary>
        /// <param name="id">Id for a learningOutcome</param>
        /// <returns></returns>
        public IActionResult Delete(int id)
        {
            LearnOutcome Lout = context.ReadOutcome(id);

            if (Lout == null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(Lout));
        }
コード例 #5
0
        /// <summary>
        /// Remove a learnOutcome from a Course
        /// </summary>
        ///
        /// <returns></returns>
        public void RemoveLOFromACourse(LearnOutcome lo, Course course)
        {
            Course       newCourse = ReadCourse(course.Id);
            LearnOutcome courseLO  = newCourse.LearnOutcomes.SingleOrDefault(m => m.Id == lo.Id);

            newCourse.LearnOutcomes.Remove(courseLO);

            _db.Courses.Update(newCourse);
            _db.SaveChanges();
        }
コード例 #6
0
        /// <summary>
        /// Update an outcome
        /// </summary>
        ///
        /// <returns></returns>
        public void UpdateOutcome(int id, LearnOutcome learnOutcome)
        {
            var oldOutcome = ReadOutcome(id);

            if (oldOutcome != null)
            {
                oldOutcome.LearningOutcome = learnOutcome.LearningOutcome;
                oldOutcome.QuestionAnswer  = learnOutcome.QuestionAnswer;
                _db.SaveChanges();
            }
        }
コード例 #7
0
        public IActionResult Add(AddLearnOutcomeViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View("Add", vm));
            }

            if (!ModelState.IsValid)
            {
                return(View("Add", vm));
            }

            LearnOutcome Lo = new LearnOutcome
            {
                LearningOutcome = vm.LearningOutcome,
                QuestionAnswer  = new List <QuesAnswer>()
            };

            Lo.QuestionAnswer.Add(context.ReadQuesAnswer(vm.QuestionId));

            context.CreateLearningOutcome(Lo);
            return(RedirectToAction("Index"));
        }
コード例 #8
0
 /// <summary>
 /// Adding a learnOutcome to a database
 /// </summary>
 /// <param name="learnOutcome">learnOutcome to add</param>
 /// <returns></returns>
 public LearnOutcome CreateLearningOutcome(LearnOutcome learnOutcome)
 {
     _db.LearnOutcome.Add(learnOutcome);
     _db.SaveChanges();
     return(learnOutcome);
 }