Ejemplo n.º 1
0
        private void LoadCourse(int courseId)
        {
            var user = Page.User as CustomPrincipal;

            var edit = hidEdit.Value;

            if (user != null)
            {
                using (var cHelper = new DbHelper.Classes())
                    using (var strHelper = new DbHelper.Structure())
                        using (var helper = new DbHelper.Subject())
                        {
                            var sub = helper.Find(courseId);
                            if (sub != null)
                            {
                                LoadSitemap(strHelper, sub);


                                txtSubjectName.Text = sub.FullName;
                                //uncomment
                                ListOfSectionsInCourseUC1.CourseId = Id;
                                lblPageTitle.Text = sub.FullName;

                                var courseStatus = cHelper.GetCourseClassesAvailabilityForUser(user.Id, sub.Id);

                                var stat = courseStatus.Split(new[] { ',' });

                                if (stat.Length >= 2)
                                {
                                    var fromCls = Request.QueryString["from"];
                                    var from    = "";
                                    if (fromCls == "detail")
                                    {
                                        from = "&from=detail";
                                    }
                                    else
                                    {
                                        from = "&from=view";
                                    }

                                    lnkMyClasses.Visible     = stat[1].Equals(DbHelper.StaticValues.Roles.Teacher);
                                    lnkMyClasses.NavigateUrl = "~/Views/Class/MyClasses.aspx?subId=" + courseId + from;
                                }

                                switch (stat[0])
                                {
                                case "current":
                                    if (stat.Length >= 3)
                                    {
                                        if (!(user.IsInRole("teacher") || user.IsInRole("manager")))
                                        {
                                            lnkEnroll.Visible     = stat[2] != "0";
                                            lnkEnroll.NavigateUrl = "~/Views/Class/SelfEnrolment.aspx?ccId=" + stat[2];
                                            lnkEnroll.Text        = "Remove Enrollment";
                                        }
                                        else
                                        {
                                            lnkEnroll.Visible = false;
                                        }

                                        //btnEnroll.Visible = stat[2] != "0";
                                        //btnEnroll.
                                    }
                                    imgJoinInfo.Visible  = true;
                                    imgJoinInfo.ImageUrl = "~/Content/Icons/Start/active_icon_10px.png";
                                    break;

                                case "complete":
                                    imgJoinInfo.Visible = true;
                                    if (!(user.IsInRole("teacher") || user.IsInRole("manager")))
                                    {
                                        imgJoinInfo.ImageUrl = "~/Content/Icons/Diploma/diploma_16px.png";
                                    }
                                    else
                                    {
                                        imgJoinInfo.ImageUrl = "~/Content/Icons/Stop/Stop_10px.png";
                                    }
                                    break;

                                case "open":
                                    //if (!(user.IsInRole("teacher") || user.IsInRole("manager")))
                                    //{

                                    //    btnEnroll.Visible = true;
                                    //    SetEnrollDialog();
                                    //}
                                    break;

                                case "close":

                                    break;

                                default:
                                    break;
                                }
                                //lblClassInformation.Text = cHelper.GetCourseClassesAvailabilityForUser(user.Id, sub.Id);
                            }
                            //CourseDetailUc1.
                        }
            }
        }