private void BindGrid() { RockContext rockContext = new RockContext(); ChangeRequestService changeRequestService = new ChangeRequestService(rockContext); var changeRequests = changeRequestService.Queryable(); if (!IsUserAuthorized(Rock.Security.Authorization.EDIT)) { var currentPersonAliasIds = CurrentPerson.Aliases.Select(a => a.Id); changeRequests = changeRequests.Where(cr => currentPersonAliasIds.Contains(cr.RequestorAliasId)); } if (!cbShowComplete.Checked) { changeRequests = changeRequests.Where(c => !c.IsComplete); } if (pEntityType.SelectedEntityTypeId.HasValue && pEntityType.SelectedEntityTypeId.Value != 0) { int entityTypeId = pEntityType.SelectedEntityTypeId.Value; //Special case for Person/Person Alias if (entityTypeId == EntityTypeCache.Get(typeof(Person)).Id) { entityTypeId = EntityTypeCache.Get(typeof(PersonAlias)).Id; } changeRequests = changeRequests.Where(c => c.EntityTypeId == entityTypeId); } changeRequests = changeRequests.OrderBy(c => c.IsComplete).ThenByDescending(c => c.CreatedDateTime); gRequests.SetLinqDataSource(changeRequests); gRequests.DataBind(); }
private void BindGrid() { RockContext rockContext = new RockContext(); ChangeRequestService changeRequestService = new ChangeRequestService(rockContext); var changeRequests = changeRequestService.Queryable(); if (!IsUserAuthorized(Rock.Security.Authorization.EDIT)) { var currentPersonAliasIds = CurrentPerson.Aliases.Select(a => a.Id); changeRequests = changeRequests.Where(cr => currentPersonAliasIds.Contains(cr.RequestorAliasId)); } if (!cbShowComplete.Checked) { changeRequests = changeRequests.Where(c => !c.IsComplete); } if (pEntityType.SelectedEntityTypeId.HasValue && pEntityType.SelectedEntityTypeId.Value != 0) { int entityTypeId = pEntityType.SelectedEntityTypeId.Value; //Special case for Person/Person Alias if (entityTypeId == EntityTypeCache.Get(typeof(Person)).Id) { entityTypeId = EntityTypeCache.Get(typeof(PersonAlias)).Id; } changeRequests = changeRequests.Where(c => c.EntityTypeId == entityTypeId); } var requests = changeRequests.Select(c => new ChangePOCO { Id = c.Id, Name = c.Name, EntityType = c.EntityType.FriendlyName, Requestor = c.RequestorAlias.Person.NickName + " " + c.RequestorAlias.Person.LastName, Requested = c.CreatedDateTime ?? Rock.RockDateTime.Today, Applied = c.ChangeRecords.Any(r => r.WasApplied), WasReviewed = c.IsComplete } ).ToList(); foreach (var request in requests) { if (request.Applied == false && request.WasReviewed == false) { request.Name = "<i class='fa fa-exclamation-triangle'></i> " + request.Name; } } requests = requests.OrderBy(c => c.WasReviewed) .ThenBy(c => c.Applied) .ThenByDescending(c => c.Requested) .ToList(); gRequests.DataSource = requests; gRequests.DataBind(); }