Example #1
0
        public void CreateCourse(Course c, List<CourseItemEntity> cis)
        {
            rep.CreateCourse(c);

            try
            {
                foreach (CourseItemEntity ci in cis)
                {
                    ci.CourseId = c.CourseId;
                    rep.CreateCourseItem(ci);
                }
            }
            catch (Exception)
            {
                DeleteCourse(c);
                throw;
            }

            //Create CoursePage
            DNNHelper d = new DNNHelper();
            string pageUrl = "C" + c.CourseId.ToString();
            string pageName = pageUrl + ": " + c.Title;
            try
            {
                TabInfo newTab = d.AddCoursePage(pageName, pageUrl);
                c.TabId = newTab.TabID;
                rep.UpdateCourse(c);
            }
            catch (Exception)
            {
                DeleteCourse(c);
                throw;
            }
        }
 public void CreateCourse(Course t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<Course>();
         rep.Insert(t);
     }
 }
Example #3
0
        public void DeleteCourse(Course c)
        {
            // Todo: Don't delete course if: It has comments or ratings
            // Todo: Soft delete of Course
            if (c == null)
            {
                throw new Exception("Cannot delete: Course not initialized");
                return;
            }

            TabController tabController = new TabController();
            TabInfo getTab = tabController.GetTab(c.TabId);

            if (getTab != null)
            {
                DNNHelper h = new DNNHelper();
                h.DeleteTab(getTab);
            }

            var cis = rep.GetItemsInCourse(c.CourseId);
            foreach (CourseItem ciDelete in cis)
            {
                rep.DeleteCourseItem(ciDelete);
            }

            rep.DeleteCourse(c);
        }