Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var id = Request.QueryString["SubId"];

                var user = Page.User as CustomPrincipal;
                if (user != null && id != null)
                {
                    //var isTeacher = user.IsInRole(DbHelper.StaticValues.Roles.Teacher);

                    ListOfSectionsInCourseUC1.UserId = user.Id;

                    using (var helper = new DbHelper.Classes())
                    {
                        var edit      = Session["editMode"] as string;//Request.QueryString["edit"];
                        var isManager = user.IsInRole(DbHelper.StaticValues.Roles.CourseEditor) ||
                                        user.IsInRole(DbHelper.StaticValues.Roles.Manager);
                        var teacher   = helper.IsTheUserTeacher(user.Id, Convert.ToInt32(id));
                        var isTeacher = isManager || teacher;

                        if (edit == "1" && isTeacher)
                        {
                            Edit = "1";
                            ListOfSectionsInCourseUC1.EditEnabled = true;
                            _path = Request.Url.AbsolutePath + "?SubId=" + id;
                        }
                        else
                        {
                            Edit = "0";
                        }
                    }
                }

                int subId = 0;
                var succ  = int.TryParse(id, out subId);
                if (succ)
                {
                    Id = subId;
                    LoadCourse(subId);
                }
            }
        }