protected void Page_Load(object sender, EventArgs e)
        {
            int?         assignmentId = Utilities.TryToParseAsInt(Request.QueryString["aid"]);
            lms_Entities db           = new ClientDBEntities();
            List <Assignment_GroupsGet_Result> allGroups = db.Assignment_GroupsGet(assignmentId).ToList();
            List <int> inAssignmentCourses = allGroups.Where(u => u.IsInAssignment == true).Select(u => u.groupId).ToList();

            cbGroups.DataSource = allGroups;
            cbGroups.DataBind();

            foreach (ListItem li in cbGroups.Items)
            {
                if (inAssignmentCourses.Contains(int.Parse(li.Value)))
                {
                    li.Selected = true;
                }
            }

            litNoResult.Visible = cbGroups.Items.Count == 0;
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lms_Entities db = new ClientDBEntities();

            lstGroups.DataSource = db.Assignment_GroupsGet(null).ToList();
            lstGroups.DataBind();

            int?userId = Utilities.TryToParseAsInt(Request.QueryString["uid"]);

            if (userId != null)
            {
                User usr = db.Users.Where(u => u.userId == userId).FirstOrDefault();
                FName.Text                    = usr.firstName;
                LName.Text                    = usr.lastName;
                tbTitle.Text                  = usr.title;
                Email.Text                    = usr.email;
                Password.Text                 = usr.password;
                cbEnabled.Checked             = usr.enabled;
                lstAccessLevels.SelectedValue = usr.role.ToString();

                //load list of organizations
                DataSet ds = new DataSet();
                ds.ReadXml(Server.MapPath("~/companies.xml"));
                ddlOrganization.DataValueField = "name";
                ddlOrganization.DataTextField  = "name";
                ddlOrganization.DataSource     = ds.Tables[0];
                ddlOrganization.DataBind();
                ddlOrganization.SelectedValue = usr.organization;

                //get group associations
                List <User_GroupsGet_Result> groups = db.User_GroupsGet(userId).ToList();
                List <int> groupIds = groups.Select(u => u.groupId).ToList();
                foreach (ListItem li in lstGroups.Items)
                {
                    if (groupIds.Contains(int.Parse(li.Value)))
                    {
                        li.Selected = true;
                    }
                }
            }
        }