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(); }
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(); } } }
protected void btnGroupSearch_Click(object sender, EventArgs e) { string searchText = txtSerachGroup.Text.Trim(); SearchResultFor = RoleType.Group; ClearGroupList(); SearchEngine search = new SearchEngine(); List <Group> listGroup = null; using (ResourceDataAccess dataAccess = new ResourceDataAccess(Utility.CreateContext())) { listGroup = dataAccess.GetGroups(searchText).OrderBy(tuple => tuple.GroupName).ToList(); } HandledExsitingGroups(listGroup); if (SelectedList != null) { SetSelectedGroup(); } }