Esempio n. 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;
            }
        }
Esempio n. 2
0
        public void CreateCourse(CourseContainer c)
        {
            if (c.CultureCode == null || c.CultureCode == "")
                throw new Exception("Cannot Create Course. CutureCode cannot be null");

            if (c.TheTitle == null || c.TheTitle.Text == null || c.TheTitle.Text == "")
                throw new Exception("Cannot Save Course. Title cannot be null");

            c.TheCourse.CreatedInCultureCode = c.CultureCode;
            c.TheCourse.CreatedOnDate = DateTime.Now;
            c.TheCourse.ModifiedByUserId = c.TheCourse.CreatedByUserId;
            c.TheCourse.ModifiedOnDate = c.TheCourse.CreatedOnDate;
            c.TheCourse.IsDeleted = false;
            c.TheCourse.IsListed = true;

            bool isNew = c.TheCourse.CourseId == 0;

            if (isNew)
            {
                rep.CreateCourse(c.TheCourse);
            }
            else
                rep.UpdateCourse(c.TheCourse);

            //Save Title
            c.TheTitle.ItemId = c.TheCourse.CourseId;
            c.TheTitle.ItemType = ETextItemType.CourseTitle;
            c.TheTitle.CultureCode = c.CultureCode;
            c.TheTitle.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
            c.TheTitle.CreatedByUserId = c.TheCourse.CreatedByUserId;
            c.TheTitle.ModifiedByUserId = c.TheCourse.ModifiedByUserId;
            SavePhTextInAllCc(c.TheTitle);  //Save or Update

            //Save Description
            if (c.TheDescription != null && c.TheDescription.Text != null && c.TheDescription.Text != "")
            {
                c.TheDescription.ItemId = c.TheCourse.CourseId;
                c.TheDescription.ItemType = ETextItemType.CourseDescription;
                c.TheDescription.CultureCode = c.CultureCode;
                c.TheDescription.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
                c.TheDescription.CreatedByUserId = c.TheCourse.CreatedByUserId;
                c.TheDescription.ModifiedByUserId = c.TheCourse.ModifiedByUserId;
                SavePhTextInAllCc(c.TheDescription);
            }
            if (c.TheRichRichText != null && c.TheRichRichText.Text != null && c.TheRichRichText.Text != "")
            {
                c.TheRichRichText.ItemId = c.TheCourse.CourseId;
                c.TheRichRichText.ItemType = ETextItemType.CourseRichRichText;
                c.TheRichRichText.CultureCode = c.CultureCode;
                c.TheRichRichText.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
                c.TheRichRichText.CreatedByUserId = c.TheCourse.CreatedByUserId;
                c.TheRichRichText.ModifiedByUserId = c.TheCourse.ModifiedByUserId;
                SavePhTextInAllCc(c.TheRichRichText);
            }
            //Create CoursePage
            if (isNew)
            {
                DNNHelper d = new DNNHelper();
                string pageUrl = "C" + c.TheCourse.CourseId.ToString();
                string pageName = pageUrl + ": " + c.TheTitle.Text;
                TabInfo newTab = d.AddCoursePage(pageName, pageUrl);
                c.TheCourse.TabId = newTab.TabID;
                rep.UpdateCourse(c.TheCourse);
            }
        }