Ejemplo n.º 1
0
        //It is assumed that all CourseItems are in the same course
        public void SaveCourseItems(IList <CourseItem> cis, int courseId, int motherId = 0)
        {
            CourseItemEntity cie = new CourseItemEntity();
            int ciOrder          = 1;

            foreach (CourseItem ci in cis)
            {
                DeleteCourseItem(ci); //Deletes heading as well if item is a heading

                if (ci.ItemType == ECourseItemType.Heading)
                {
                    CourseMenuHeadings ch = new CourseMenuHeadings();
                    ch.Title = ci.name;
                    rep.CreateHeading(ch);
                    cie.ItemId = ch.HeadingID;
                }
                else
                {
                    cie.ItemId = ci.ItemId;
                }

                cie.CourseId = courseId;
                cie.CIOrder  = ciOrder;
                cie.ItemType = ci.ItemType;
                cie.MotherId = motherId;
                rep.CreateCourseItem(cie);
                ciOrder += 1;
                if (ci.children != null)
                {
                    SaveCourseItems(ci.children, courseId, cie.CourseItemId);
                }
            }
        }
Ejemplo n.º 2
0
 public void CreateCourseItem(CourseItemEntity t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<CourseItemEntity>();
         rep.Insert(t);
     }
 }
Ejemplo n.º 3
0
 public void DeleteCourseItem(CourseItemEntity t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository <CourseItemEntity>();
         rep.Delete(t);
     }
 }
Ejemplo n.º 4
0
        //It is assumed that all CourseItems are in the same course
        public void SaveCourseItems(IList<CourseItem> cis, int courseId, int motherId = 0)
        {
            CourseItemEntity cie = new CourseItemEntity();
            int ciOrder = 1;
            foreach (CourseItem ci in cis)
            {
                DeleteCourseItem(ci); //Deletes heading as well if item is a heading

                if (ci.ItemType == ECourseItemType.Heading)
                {
                    CourseMenuHeadings ch = new CourseMenuHeadings();
                    ch.Title = ci.name;
                    rep.CreateHeading(ch);
                    cie.ItemId = ch.HeadingID;
                }
                else
                    cie.ItemId = ci.ItemId;

                cie.CourseId = courseId;
                cie.CIOrder = ciOrder;
                cie.ItemType = ci.ItemType;
                cie.MotherId = motherId;
                rep.CreateCourseItem(cie);
                ciOrder += 1;
                if (ci.children != null)
                    SaveCourseItems(ci.children, courseId, cie.CourseItemId);
            }
        }