Exemplo n.º 1
0
    private void FillGroupGrid()
    {
        string searchText = txtSearchText.Text.Trim();

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

        grdGroupSearchResult.PageSize = _pageSize;

        List <Group> groupList = null;

        using (ResourceDataAccess dataAccess = new ResourceDataAccess(Utility.CreateContext()))
        {
            IEnumerable <Group> groups = null;

            if (rbSearchOptions.SelectedItem.Text.Equals(Resources.Resources.SearchInExistingList))
            {
                groups = dataAccess.GetGroupsWithExplicitPermissions(resourceId, searchText, userToken);
            }
            else
            {
                groups = dataAccess.GetGroups(searchText);
            }

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

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

        if (groupList != null)
        {
            //Update page count
            UpdatePageCount(grdGroupSearchResult, totalRecords);

            if (groupList.Count > 0)
            {
                grdGroupSearchResult.DataSource = groupList;
                grdGroupSearchResult.DataBind();
            }
        }
    }