private void LoadCourseDetail() { using (var helper = new DbHelper.Subject()) { var course = helper.Find(CourseId); //lblTitle.Text = course.Name; //lblSummary.Text = course.Summary; if (course != null) { var sections = course.SubjectSections; if (sections != null) { var unVoidedSections = sections.Where(x => !(x.Void ?? false)); foreach (var subjectSection in unVoidedSections) { SectionUc sectionuc = (SectionUc)Page.LoadControl("~/Views/Course/Section/SectionUc.ascx"); sectionuc.SummaryVisible = subjectSection.ShowSummary ?? false; sectionuc.SubjectId = subjectSection.SubjectId; sectionuc.SectionId = subjectSection.Id; pnlSections.Controls.Add(sectionuc); } } } } //CreateSectionUc uc = (CreateSectionUc)Page.LoadControl("~/Views/Course/Section/CreateSectionUc.ascx"); //uc.ID = "createSection"; //uc.Visible = false; //uc.SubjectId = CourseId; //uc.OnSaveEvent += uc_OnSaveEvent; //pnlSections.Controls.Add(uc); }
private void LoadCourseDetail() { var courseId = CourseId; using (var helper = new DbHelper.Subject()) { lnkAddSection1.NavigateUrl = "~/Views/Course/Section/CreateSection.aspx?SubId=" + courseId; var course = helper.Find(courseId); //lblTitle.Text = course.Name; //lblSummary.Text = course.Summary; if (course != null) { var sections = course.SubjectSections; if (sections != null) { var user = Page.User as CustomPrincipal; var elligible = false; if (user != null) { using (var chelper = new DbHelper.Classes()) { var roles = user.GetRoles(); //Context.UserClass.Any(x=>x.subje) // var roles = user.GetRoles().Select(x => x.Role.RoleName).ToList(); if (roles.Contains(DbHelper.StaticValues.Roles.CourseEditor.ToString()) || roles.Contains(DbHelper.StaticValues.Roles.Manager.ToString()) || roles.Contains(DbHelper.StaticValues.Roles.Admin) || roles.Contains("teacher")) { elligible = true; } //else //{ // //teacher // elligible = (chelper.IsUserElligibleToViewSubjectSection(SubjectId, UserId)); //} var unVoidedSections = sections.Where(x => !(x.Void ?? false)).OrderBy(x => x.Position); using (var ahelper = new DbHelper.ActAndRes()) foreach (var subjectSection in unVoidedSections) { var canView = elligible; if (!canView) { canView = ahelper.EvaluateRestriction(null, subjectSection.Restriction, user.Id); } if (canView) // { SectionUc sectionuc = (SectionUc)Page.LoadControl("~/Views/Course/Section/SectionUc.ascx"); sectionuc.AddActResClicked += sectionuc_AddActResClicked; //sectionuc.EditEnabled = EditEnabled; //sectionuc.SummaryVisible = subjectSection.ShowSummary ?? false; //sectionuc.SubjectId = subjectSection.SubjectId; //sectionuc.SectionId = subjectSection.Id; //sectionuc.SectionName = subjectSection.Name; sectionuc.SetData(EditEnabled, subjectSection.ShowSummary ?? false , subjectSection.SubjectId, subjectSection.Id , subjectSection.Name, UserId, elligible); var sectionlbl = new Literal() { Text = "<a name='section_" + subjectSection.Id + "'></a>" }; pnlSections.Controls.Add(sectionlbl); pnlSections.Controls.Add(sectionuc); } } } } } } } //CreateSectionUc uc = (CreateSectionUc)Page.LoadControl("~/Views/Course/Section/CreateSectionUc.ascx"); //uc.ID = "createSection"; //uc.Visible = false; //uc.SubjectId = CourseId; //uc.OnSaveEvent += uc_OnSaveEvent; //pnlSections.Controls.Add(uc); }