Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        userToken = Session[Constants.AuthenticationTokenKey] as AuthenticatedToken;

        if (!Page.IsPostBack)
        {
            using (ZentityContext context = Utility.CreateContext())
            {
                if (ControlMode == RoleType.Group)
                {
                    List <Group> listGroup = new List <Group>();
                    using (ResourceDataAccess dataAccess = new ResourceDataAccess(Utility.CreateContext()))
                    {
                        listGroup = dataAccess.GetGroups(string.Empty).OrderBy(tuple => tuple.GroupName).ToList();
                    }

                    HandledExsitingGroups(listGroup);
                }
                else if (ControlMode == RoleType.User)
                {
                    List <Identity> listIdentity = new List <Identity>();

                    using (ResourceDataAccess dataAccess = new ResourceDataAccess(Utility.CreateContext()))
                    {
                        listIdentity = dataAccess.GetIdentities(string.Empty).OrderBy(tuple => tuple.IdentityName).ToList();
                    }
                    HandledExsitingIdentities(listIdentity);
                }
                else
                {
                    List <Resource> listResource = context.Resources.ToList();

                    foreach (Resource resource in listResource)
                    {
                        if (SelectedMode == ListSelectionMode.Single)
                        {
                            lstGroupList.Items.Add(new ListItem(resource.Title, resource.Id.ToString()));
                            chkGroupList.Visible = false;
                            lstGroupList.Visible = true;
                        }
                        else
                        {
                            chkGroupList.Items.Add(new ListItem(resource.Title, resource.Id.ToString()));
                        }
                    }
                }
            }
        }

        InitializeLabels();
    }
Ejemplo n.º 2
0
    private void FillUserGrid()
    {
        string searchText = txtSearchText.Text.Trim();

        int totalRecords   = 0;
        int fetchedRecords = _pageSize * grdVwSearchResult.PageIndex;

        grdVwSearchResult.PageSize = _pageSize;

        List <Identity> identityList = null;

        using (ResourceDataAccess dataAccess = new ResourceDataAccess(Utility.CreateContext()))
        {
            IEnumerable <Identity> identities = null;
            if (rbSearchOptions.SelectedItem.Text.Equals(Resources.Resources.SearchInExistingList))
            {
                identities = dataAccess.GetIdentitiesWithExplicitPermissions(resourceId, searchText, userToken);
            }
            else
            {
                identities = dataAccess.GetIdentities(searchText);
            }

            totalRecords = identities.Count();
            identities   = identities.OrderBy(tuple => tuple.Title).Skip(fetchedRecords).Take(_pageSize);
            identityList = identities.ToList();

            if (!(totalRecords > 0))
            {
                lblErrorOrMessage.Text    = Resources.Resources.NoRecordsFound;
                lblErrorOrMessage.Visible = true;
            }
            Utility.UpdateResourcesEmptyTitle(identityList);
        }

        if (identityList != null)
        {
            //Update page count
            UpdatePageCount(grdVwSearchResult, totalRecords);

            if (identityList.Count > 0)
            {
                grdVwSearchResult.DataSource = identityList;
                grdVwSearchResult.DataBind();
            }
        }
    }
Ejemplo n.º 3
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string searchText = txtSerachGroup.Text.Trim();

        SearchResultFor = RoleType.User;
        ClearGroupList();
        List <Identity> listIdentity = null;

        using (ResourceDataAccess dataAccess = new ResourceDataAccess(Utility.CreateContext()))
        {
            listIdentity = dataAccess.GetIdentities(searchText).OrderBy(tuple => tuple.IdentityName).ToList();
        }

        HandledExsitingIdentities(listIdentity);
        if (SelectedIdentityList != null)
        {
            SetSelectedIdentity();
        }
    }