public ActionResult AddLOsToCourse(Course course) { string stringOfLoIds = Request["selectedIds"]; if (!stringOfLoIds.IsEmpty()) { List<string> listOfLoIds = stringOfLoIds.Split(',').ToList(); foreach (var id in listOfLoIds) { var id1 = id; var lo = _dbContext.LOs.Find(x => x.Id == ObjectId.Parse(id1)).SingleAsync().Result; if (lo != null) { course.Duration += lo.Duration; course.AddLo(lo.Id); } } } ModelState.Clear(); if (course.Id != ObjectId.Empty) { _logger.Trace("LO or LOs added to course during course editing"); return View("EditCourse", course); } else { _logger.Trace("LO or LOs added to course during manual course creating"); return View("ManualCourseCreating", course); } }
public ActionResult AddLOsToCourse(Course course) { string stringOfLoIds = Request["selectedIds"]; if (!stringOfLoIds.IsEmpty()) { List<string> listOfLoIds = stringOfLoIds.Split(',').ToList(); foreach (var id in listOfLoIds) { //var lo = db.GetLOByID(id); var lo = _dbContext.LOs.Find(x => x.Id == ObjectId.Parse(id)).ToListAsync().Result; if (lo != null) { course.AddLo(ObjectId.Parse(id)); } } } if (course.Id != ObjectId.Empty) { return View("EditCourse", course); } else { return View("ManualCourseCreating", course); } }