コード例 #1
0
        public void InitializeRoles()
        {
            List<UserRole> USER_ROLES = new List<UserRole>();
            var can_insert_role = new UserRole
            {
                 Role = "CAN INSERT",
                 UserId = int.Parse(hfUserId.Value)
            };
            var can_delete_role = new UserRole
            {
                Role = "CAN DELETE",
                UserId = int.Parse(hfUserId.Value)
            };
            var can_update_role = new UserRole
            {
                Role = "CAN UPDATE",
                UserId = int.Parse(hfUserId.Value)
            };
            USER_ROLES.Add(can_insert_role);
            USER_ROLES.Add(can_delete_role);
            USER_ROLES.Add(can_update_role);

            chkUserRoles.DataSource = USER_ROLES;
            chkUserRoles.DataTextField = "Role";
            chkUserRoles.DataValueField = "Role";
            chkUserRoles.DataBind();
        }
コード例 #2
0
 private List<UserRole> GetAllUserRolesToSave()
 {
     List<UserRole> UserRoles = new List<UserRole>();
     for (int i = 0; i < this.chkBoxAccessGrant.Items.Count; i++)
     {
         if (chkBoxAccessGrant.Items[i].Selected)
         {
             UserRole ur = new UserRole();
             ur.Role = chkBoxAccessGrant.Items[i].Value;
             ur.UserId = int.Parse(hfUserID.Value);
             ur.DateRecorded = DateTime.UtcNow;
             UserRoles.Add(ur);
         }
     }
     if (UserRoles.Count < 1)
     {
         return new List<UserRole>();
     }
     return UserRoles;
 }