/// <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(); }
/// <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(); }
/// <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)); }
/// <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)); }
/// <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(); }
/// <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(); } }
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")); }
/// <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); }