Example #1
0
 public void CreateCoursePlugg(CoursePluggEntity t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<CoursePluggEntity>();
         rep.Insert(t);
     }
 }
Example #2
0
 private void CreateCP(int order, int motherId)
 {
     string[] pluggIds = txtAddPlugg.Text.Trim().Split(',');
     BaseHandler bh = new BaseHandler();
     for (int i = 0; i < pluggIds.Length; i++)
     {
         CoursePluggEntity newCP = new CoursePluggEntity();
         newCP.CourseId = CourseId;
         newCP.MotherId = motherId;
         newCP.CreatedByUserId = UserId;
         newCP.PluggId = Convert.ToInt32(pluggIds[i]);
         newCP.CPOrder = order+i;
         bh.CreateCP(newCP);
     }
     txtAddPlugg.Text = "";
     lblPluggInfo.Text = "";
     BindTree();
 }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    BaseHandler bh = new BaseHandler();
                    CultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
                    PluggId = Convert.ToInt32(((DotNetNuke.Framework.CDefault)this.Page).Title);

                    string coursePluggIdStr = Page.Request.QueryString["cp"];
                    if (coursePluggIdStr == null)    //This is a Plugg outside a course: no menu
                        return;

                    bool isNum = int.TryParse(coursePluggIdStr, out CoursePluggId);
                    if (!isNum)
                        return;

                    currentCPE = bh.GetCPEntity(CoursePluggId);
                    if (currentCPE == null)
                        return;
                    CourseId = currentCPE.CourseId;
                    cc = new CourseContainer(CultureCode, CourseId);
                    if (cc == null)
                        return;
                    pnlTitle.Visible = true;
                    hlBackToCourse.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(cc.TheCourse.TabId, "", "");
                    cc.LoadPluggs();
                    CoursePlugg currentCP = bh.FindCoursePlugg(CultureCode, CourseId, CoursePluggId);
                    CoursePlugg nextCP = bh.NextCoursePlugg(currentCP);
                    if (nextCP != null)
                    {
                        PluggContainer p = new PluggContainer(CultureCode, nextCP.PluggId);
                        lnkNextPlugg.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(p.ThePlugg.TabId, "", "cp=" + nextCP.CoursePluggId );
                    }
                    else
                    {
                        lnkNextPlugg.Enabled = false;
                    }

                    PopulateTreeNodes((List<CoursePlugg>)cc.ThePluggs, TreeViewMain.Nodes);
                }

            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                BaseHandler bh = new BaseHandler();
                CultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;

                string coursePluggIdStr = Page.Request.QueryString["cp"];
                if (coursePluggIdStr == null)    //This is a Plugg outside a course: no menu
                    return;

                bool isNum = int.TryParse(coursePluggIdStr, out CoursePluggId);
                if (!isNum)
                    return;

                currentCPE = bh.GetCPEntity(CoursePluggId);
                if (currentCPE == null)
                    return;
                CourseId = currentCPE.CourseId;
                cc = new CourseContainer(CultureCode, CourseId);
                if (cc == null)
                    return;

                InCreationLanguage = (cc.TheCourse.CreatedInCultureCode == CultureCode);
                IsAuthorized = ((this.UserId != -1 && cc.TheCourse.WhoCanEdit == EWhoCanEdit.Anyone) || cc.TheCourse.CreatedByUserId == this.UserId || (UserInfo.IsInRole("Administator")));
                Edit = !string.IsNullOrEmpty(Page.Request.QueryString["editcp"]) ? Convert.ToInt16(Page.Request.QueryString["editcp"]) : -1;
                Translate = !string.IsNullOrEmpty(Page.Request.QueryString["translatecp"]) ? Convert.ToInt16(Page.Request.QueryString["translatecp"]) : -1;

                PHText theComment = bh.GetCurrentVersionText(CultureCode, CoursePluggId, ETextItemType.CoursePluggText);
                if (theComment != null && Edit == -1 && Translate == -1)
                    TheText.Text = theComment.Text;

                #region hide/display controls
                if (!InCreationLanguage && UserId > -1 && Translate == -1)
                {
                    phTranslate.Visible = true;
                    hlTranslate.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "translatecp=0", "cp=" + CoursePluggId);
                }

                if (InCreationLanguage && IsAuthorized && Edit == -1)
                {
                    phEditCPComment.Visible = true;
                    if (theComment==null)
                        hlEditCPComment.Text = Localization.GetString("AddCPComment", this.LocalResourceFile);
                    else
                        hlEditCPComment.Text = Localization.GetString("EditCPComment", this.LocalResourceFile);
                    hlEditCPComment.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "editcp=0", "cp=" + CoursePluggId);
                }

                if (!InCreationLanguage && UserId > -1 && Translate > -1)
                {
                    phExitTranslate.Visible = true;
                    hlExitTranslate.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "cp=" + CoursePluggId);
                    RichControl ucR = (RichControl)this.LoadControl("/DesktopModules/PlugghestControls/RichControl.ascx");
                    if ((ucR != null))
                    {
                        ucR.ModuleConfiguration = this.ModuleConfiguration;
                        ucR.ItemId = CoursePluggId;
                        ucR.CultureCode = CultureCode;
                        ucR.CreatedInCultureCode = CultureCode;
                        ucR.CreatedInCultureCode = cc.TheCourse.CreatedInCultureCode;
                        ucR.ControlOrder = 1;
                        ucR.ItemType = ETextItemType.CoursePluggText;
                        ucR.Case = EControlCase.ViewAllowTranslate;
                        if (Translate == 1)
                            ucR.Case = EControlCase.Translate;
                        ucR.LocalResourceFile = "/DesktopModules/PlugghestControls/App_LocalResources/RichControl.ascx";
                        phTheText.Controls.Add(ucR);
                    }
                }

                if (InCreationLanguage && IsAuthorized && Edit > -1)
                {
                    plInfo.Visible = true;
                    RichControl ucR = (RichControl)this.LoadControl("/DesktopModules/PlugghestControls/RichControl.ascx");
                    if ((ucR != null))
                    {
                        ucR.ModuleConfiguration = this.ModuleConfiguration;
                        ucR.ItemId = CoursePluggId;
                        ucR.CultureCode = CultureCode;
                        ucR.CreatedInCultureCode = CultureCode;
                        ucR.ControlOrder = 1;
                        ucR.ItemType = ETextItemType.CoursePluggText;
                        ucR.Case = EControlCase.Edit;
                        ucR.LocalResourceFile = "/DesktopModules/PlugghestControls/App_LocalResources/RichControl.ascx";
                        phTheText.Controls.Add(ucR);
                    }
                }
                #endregion

            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Example #5
0
 public void CreateCP(CoursePluggEntity cp)
 {
     if (cp == null || cp.CoursePluggId != 0 || cp.CPOrder == 0)
         throw new Exception("Cannot create CoursePlugg");
     IEnumerable<CoursePluggEntity> sameMother = rep.GetChildrenCP(cp.MotherId);
     foreach (CoursePluggEntity tmpCP in sameMother)
     {
         if (tmpCP.CPOrder >= cp.CPOrder)
         {
             tmpCP.CPOrder++;
             rep.UpdateCoursePlugg(tmpCP);
         }
     }
     cp.CreatedOnDate = DateTime.Now;
     rep.CreateCoursePlugg(cp);
 }
Example #6
0
 private void AddBrothersToCourse(List<CoursePlugg> brothers, int courseIdReceiver, int motherId, int userId)
 {
     foreach (CoursePlugg cp in brothers)
     {
         CoursePluggEntity cpe = new CoursePluggEntity();
         cpe.CourseId = courseIdReceiver;
         cpe.CPOrder = cp.CPOrder;
         cpe.CreatedByUserId = userId;
         cpe.CreatedOnDate = DateTime.Now;
         cpe.MotherId = motherId;
         cpe.PluggId = cp.PluggId;
         rep.CreateCoursePlugg(cpe);
         if (cp.children.Count > 0)
             AddBrothersToCourse(cp.children, courseIdReceiver, cpe.CoursePluggId, userId);
     }
 }