예제 #1
0
        public static Expression <Func <Workflow, bool> > GetWorkflowsRegionIdPredicate(IEnumerable <int?> regionIds)
        {
            var predicate = PredicateBuilder.Create <Workflow>(wf => false);

            foreach (var regionId in regionIds)
            {
                var rid = regionId.GetValueOrDefault();
                predicate = predicate.Or(wf => wf.UnliquidatedObligation.RegionId == rid);
            }
            return(predicate);
        }
예제 #2
0
        public static Expression <Func <Workflow, bool> > GetWorkflowsWorkflowIdPredicate(IEnumerable <int> workflowIds)
        {
            /*
             * var workflows = DB.Workflows.Where(w => workflowIds.Contains(w.WorkflowId));
             * For whatever reason, linq 2 sql wont translate the above into an IN statement (maybe it only does this for string),
             * As such, we have to build out a big long nasty OR predicate then apply which we do below.
             */
            var predicate = PredicateBuilder.Create <Workflow>(wf => false);

            foreach (var wfid in workflowIds)
            {
                predicate = predicate.Or(wf => wf.WorkflowId == wfid);
            }
            return(predicate);
        }
예제 #3
0
        public static Expression <Func <Workflow, bool> > GenerateWorkflowPredicate(IPrincipal currentUser, int?uloId, string pegasysDocumentNumber, string organization,
                                                                                    int?region, int?zone, string fund, string baCode, string pegasysTitleNumber, string pegasysVendorName, string docType, string contractingOfficersName, string currentlyAssignedTo, string hasBeenAssignedTo, string awardNumber, string reasonIncludedInReview, bool?valid, string status, int?reviewId, bool?reassignableByMe)
        {
            pegasysDocumentNumber = StringHelpers.TrimOrNull(pegasysDocumentNumber);
            organization          = StringHelpers.TrimOrNull(organization);
            fund                    = StringHelpers.TrimOrNull(fund);
            baCode                  = StringHelpers.TrimOrNull(baCode);
            pegasysTitleNumber      = StringHelpers.TrimOrNull(pegasysTitleNumber);
            pegasysVendorName       = StringHelpers.TrimOrNull(pegasysVendorName);
            docType                 = StringHelpers.TrimOrNull(docType);
            contractingOfficersName = StringHelpers.TrimOrNull(contractingOfficersName);
            currentlyAssignedTo     = StringHelpers.TrimOrNull(currentlyAssignedTo);
            hasBeenAssignedTo       = StringHelpers.TrimOrNull(hasBeenAssignedTo);
            awardNumber             = StringHelpers.TrimOrNull(awardNumber);
            reasonIncludedInReview  = StringHelpers.TrimOrNull(reasonIncludedInReview);
            status                  = StringHelpers.TrimOrNull(status);

            if (uloId == null &&
                pegasysDocumentNumber == null &&
                organization == null &&
                region == null &&
                zone == null &&
                fund == null &&
                baCode == null &&
                pegasysTitleNumber == null &&
                pegasysVendorName == null &&
                docType == null &&
                contractingOfficersName == null &&
                currentlyAssignedTo == null &&
                hasBeenAssignedTo == null &&
                awardNumber == null &&
                reasonIncludedInReview == null &&
                valid == null &&
                status == null &&
                reviewId == null &&
                !reassignableByMe.GetValueOrDefault())
            {
                return(null);
            }

            var originalPredicate = PredicateBuilder.Create <Workflow>(wf => true);

            var predicate = originalPredicate;

            if (uloId != null)
            {
                predicate = predicate.And(wf => wf.TargetUloId == uloId);
            }

            if (pegasysDocumentNumber != null)
            {
                var criteria = pegasysDocumentNumber.Replace(Wildcard, "");
                if (pegasysDocumentNumber.StartsWith(Wildcard) && pegasysDocumentNumber.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysDocumentNumber.Contains(criteria));
                }
                else if (pegasysDocumentNumber.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysDocumentNumber.TrimEnd().EndsWith(criteria));
                }
                else if (pegasysDocumentNumber.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysDocumentNumber.TrimStart().StartsWith(criteria));
                }
                else
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysDocumentNumber.Trim() == criteria);
                }
            }

            if (organization != null)
            {
                var criteria = organization.Replace(Wildcard, "");
                if (organization.StartsWith(Wildcard) && organization.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Organization.Contains(criteria));
                }
                else if (organization.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Organization.Trim().EndsWith(criteria));
                }
                else if (organization.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Organization.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate =
                        predicate.And(wf => wf.UnliquidatedObligation.Organization.Trim() == criteria);
                }
            }

            if (region != null)
            {
                predicate = predicate.And(wf => wf.UnliquidatedObligation.RegionId == region);
            }

            if (zone != null)
            {
                predicate = predicate.And(wf => wf.UnliquidatedObligation.Region.ZoneId == zone);
            }

            if (fund != null)
            {
                var criteria = fund.Replace(Wildcard, "");
                if (fund.StartsWith(Wildcard) && fund.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Fund.Contains(criteria));
                }
                else if (fund.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Fund.Trim().EndsWith(criteria));
                }
                else if (fund.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Fund.StartsWith(criteria));
                }
                else
                {
                    predicate = predicate.And(wf => wf.UnliquidatedObligation.Fund.Trim() == criteria);
                }
            }

            if (baCode != null)
            {
                var criteria = baCode.Replace(Wildcard, "");
                if (baCode.StartsWith(Wildcard) && baCode.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Prog.Contains(criteria));
                }
                else if (baCode.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Prog.Trim().EndsWith(criteria));
                }
                else if (baCode.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Prog.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate = predicate.And(wf => wf.UnliquidatedObligation.Prog.Trim() == criteria);
                }
            }

            if (pegasysTitleNumber != null)
            {
                var criteria = pegasysTitleNumber.Replace(Wildcard, "");
                if (pegasysTitleNumber.StartsWith(Wildcard) && pegasysTitleNumber.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysTitleNumber.Contains(criteria));
                }
                else if (pegasysTitleNumber.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysTitleNumber.Trim().EndsWith(criteria));
                }
                else if (pegasysTitleNumber.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysTitleNumber.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate =
                        predicate.And(
                            wf =>
                            wf.UnliquidatedObligation.PegasysTitleNumber.Trim() ==
                            criteria);
                }
            }

            if (pegasysVendorName != null)
            {
                var criteria = pegasysVendorName.Replace(Wildcard, "");
                if (pegasysVendorName.StartsWith(Wildcard) && pegasysVendorName.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.VendorName.Contains(criteria));
                }
                else if (pegasysVendorName.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.VendorName.Trim().EndsWith(criteria));
                }
                else if (pegasysVendorName.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.VendorName.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate =
                        predicate.And(wf =>
                                      wf.UnliquidatedObligation.VendorName.Trim() == criteria);
                }
            }

            if (docType != null)
            {
                predicate =
                    predicate.And(
                        wf => wf.UnliquidatedObligation.DocType == docType);
            }

            if (contractingOfficersName != null)
            {
                var criteria = contractingOfficersName.Replace(Wildcard, "");
                if (contractingOfficersName.StartsWith(Wildcard) && contractingOfficersName.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.ContractingOfficersName.Contains(criteria));
                }
                else if (contractingOfficersName.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.ContractingOfficersName.Trim().EndsWith(criteria));
                }
                else if (contractingOfficersName.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.ContractingOfficersName.StartsWith(criteria));
                }
                else
                {
                    predicate =
                        predicate.And(
                            wf =>
                            wf.UnliquidatedObligation.ContractingOfficersName.Trim() ==
                            criteria);
                }
            }

            if (currentlyAssignedTo != null)
            {
                var criteria = currentlyAssignedTo.Replace(Wildcard, "");
                if (currentlyAssignedTo.StartsWith(Wildcard) && currentlyAssignedTo.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.AspNetUser.UserName.Contains(criteria));
                }
                else if (currentlyAssignedTo.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.AspNetUser.UserName.Trim().EndsWith(criteria));
                }
                else if (currentlyAssignedTo.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.AspNetUser.UserName.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate = predicate.And(wf => wf.AspNetUser.UserName.Trim() == currentlyAssignedTo);
                }
            }

            if (hasBeenAssignedTo != null)
            {
                var criteria = hasBeenAssignedTo.Replace(Wildcard, "");
                if (hasBeenAssignedTo.StartsWith(Wildcard) && hasBeenAssignedTo.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.WorkflowHistories.Any(wfh => wfh.AspNetUser.UserName.Contains(criteria)));
                }
                else if (hasBeenAssignedTo.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.WorkflowHistories.Any(wfh => wfh.AspNetUser.UserName.EndsWith(criteria)));
                }
                else if (hasBeenAssignedTo.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.WorkflowHistories.Any(wfh => wfh.AspNetUser.UserName.StartsWith(criteria)));
                }
                else
                {
                    predicate =
                        predicate.And(
                            wf => wf.WorkflowHistories.Any(wfh => wfh.AspNetUser.UserName == criteria));
                }
            }

            if (awardNumber != null)
            {
                var criteria = awardNumber.Replace(Wildcard, "");
                if (awardNumber.StartsWith(Wildcard) && awardNumber.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.AwardNbr.Contains(criteria));
                }
                else if (awardNumber.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.AwardNbr.Trim().EndsWith(criteria));
                }
                else if (awardNumber.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.AwardNbr.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate = predicate.And(wf => wf.UnliquidatedObligation.AwardNbr.Trim() == criteria);
                }
            }

            if (reasonIncludedInReview != null)
            {
                var criteria = reasonIncludedInReview.Replace(Wildcard, "");
                if (reasonIncludedInReview.StartsWith(Wildcard) && reasonIncludedInReview.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.ReasonIncludedInReview.Contains(criteria));
                }
                else if (reasonIncludedInReview.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.ReasonIncludedInReview.Trim().EndsWith(criteria));
                }
                else if (reasonIncludedInReview.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.ReasonIncludedInReview.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate =
                        predicate.And(
                            wf =>
                            wf.UnliquidatedObligation.ReasonIncludedInReview.Trim() ==
                            criteria);
                }
            }

            if (valid.HasValue)
            {
                predicate = predicate.And(wf => wf.UnliquidatedObligation.Valid == valid);
            }

            if (status != null)
            {
                var criteria = status.Replace(Wildcard, "");
                if (status.StartsWith(Wildcard) && status.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Status.Contains(criteria));
                }
                else if (status.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Status.Trim().EndsWith(criteria));
                }
                else if (status.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Status.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate = predicate.And(wf => wf.UnliquidatedObligation.Status.Trim() == criteria);
                }
            }

            if (reviewId != null)
            {
                predicate = predicate.And(wf => wf.UnliquidatedObligation.ReviewId == reviewId);
            }

            if (reassignableByMe.GetValueOrDefault())
            {
                var regionIds = GetUserGroupRegions(currentUser, PortalHelpers.ReassignGroupUserId);
                predicate = predicate.And(GetWorkflowsRegionIdPredicate(regionIds));
            }

            return(predicate);
        }
예제 #4
0
        public static Expression <Func <Workflow, bool> > GenerateWorkflowPredicate(IPrincipal currentUser, int?uloId, string pegasysDocumentNumber, string organization,
                                                                                    IList <int> regions, IList <int> zones, string fund, IList <string> baCode, string pegasysTitleNumber, string pegasysVendorName, IList <string> docType, string contractingOfficersName, string currentlyAssignedTo, string hasBeenAssignedTo, string awardNumber, IList <string> reasonIncludedInReview, IList <bool> valid, IList <string> status, IList <int> reviewId, bool?reassignableByMe)
        {
            pegasysDocumentNumber = StringHelpers.TrimOrNull(pegasysDocumentNumber);
            organization          = StringHelpers.TrimOrNull(organization);
            fund = StringHelpers.TrimOrNull(fund);
            pegasysTitleNumber      = StringHelpers.TrimOrNull(pegasysTitleNumber);
            pegasysVendorName       = StringHelpers.TrimOrNull(pegasysVendorName);
            contractingOfficersName = StringHelpers.TrimOrNull(contractingOfficersName);
            currentlyAssignedTo     = StringHelpers.TrimOrNull(currentlyAssignedTo);
            hasBeenAssignedTo       = StringHelpers.TrimOrNull(hasBeenAssignedTo);
            awardNumber             = StringHelpers.TrimOrNull(awardNumber);
            reasonIncludedInReview  = reasonIncludedInReview ?? Empty.StringArray;

            bool hasFilters = false;

            var originalPredicate = PredicateBuilder.Create <Workflow>(wf => true);

            var predicate = originalPredicate;

            if (uloId != null)
            {
                hasFilters = true;
                predicate  = predicate.And(wf => wf.TargetUloId == uloId);
            }

            if (pegasysDocumentNumber != null)
            {
                hasFilters = true;
                var criteria = pegasysDocumentNumber.Replace(Wildcard, "");
                if (pegasysDocumentNumber.StartsWith(Wildcard) && pegasysDocumentNumber.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysDocumentNumber.Contains(criteria));
                }
                else if (pegasysDocumentNumber.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysDocumentNumber.TrimEnd().EndsWith(criteria));
                }
                else if (pegasysDocumentNumber.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysDocumentNumber.TrimStart().StartsWith(criteria));
                }
                else
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysDocumentNumber.Trim() == criteria);
                }
            }

            if (organization != null)
            {
                hasFilters = true;
                var criteria = organization.Replace(Wildcard, "");
                if (organization.StartsWith(Wildcard) && organization.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Organization.Contains(criteria));
                }
                else if (organization.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Organization.Trim().EndsWith(criteria));
                }
                else if (organization.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Organization.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate =
                        predicate.And(wf => wf.UnliquidatedObligation.Organization.Trim() == criteria);
                }
            }

            if (regions != null && regions.Count > 0)
            {
                hasFilters = true;
                predicate  = predicate.And(wf => wf.UnliquidatedObligation.RegionId != null && regions.Contains((int)wf.UnliquidatedObligation.RegionId));
            }

            if (zones != null && zones.Count > 0)
            {
                hasFilters = true;
                predicate  = predicate.And(wf => zones.Contains(wf.UnliquidatedObligation.Region.ZoneId));
            }

            if (fund != null)
            {
                hasFilters = true;
                var criteria = fund.Replace(Wildcard, "");
                if (fund.StartsWith(Wildcard) && fund.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Fund.Contains(criteria));
                }
                else if (fund.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Fund.Trim().EndsWith(criteria));
                }
                else if (fund.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.Fund.StartsWith(criteria));
                }
                else
                {
                    predicate = predicate.And(wf => wf.UnliquidatedObligation.Fund.Trim() == criteria);
                }
            }

            if (baCode != null && baCode.Count > 0)
            {
                hasFilters = true;
                predicate  = predicate.And(wf => baCode.Contains(wf.UnliquidatedObligation.Prog.Trim()));
            }

            if (pegasysTitleNumber != null)
            {
                hasFilters = true;
                var criteria = pegasysTitleNumber.Replace(Wildcard, "");
                if (pegasysTitleNumber.StartsWith(Wildcard) && pegasysTitleNumber.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysTitleNumber.Contains(criteria));
                }
                else if (pegasysTitleNumber.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysTitleNumber.Trim().EndsWith(criteria));
                }
                else if (pegasysTitleNumber.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.PegasysTitleNumber.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate =
                        predicate.And(
                            wf =>
                            wf.UnliquidatedObligation.PegasysTitleNumber.Trim() ==
                            criteria);
                }
            }

            if (pegasysVendorName != null)
            {
                hasFilters = true;
                var criteria = pegasysVendorName.Replace(Wildcard, "");
                if (pegasysVendorName.StartsWith(Wildcard) && pegasysVendorName.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.VendorName.Contains(criteria));
                }
                else if (pegasysVendorName.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.VendorName.Trim().EndsWith(criteria));
                }
                else if (pegasysVendorName.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.VendorName.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate =
                        predicate.And(wf =>
                                      wf.UnliquidatedObligation.VendorName.Trim() == criteria);
                }
            }

            if (docType != null && docType.Count > 0)
            {
                hasFilters = true;
                predicate  = predicate.And(wf => docType.Contains(wf.UnliquidatedObligation.DocType));
            }

            if (contractingOfficersName != null)
            {
                hasFilters = true;
                var criteria = contractingOfficersName.Replace(Wildcard, "");
                if (contractingOfficersName.StartsWith(Wildcard) && contractingOfficersName.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.ContractingOfficersName.Contains(criteria));
                }
                else if (contractingOfficersName.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.ContractingOfficersName.Trim().EndsWith(criteria));
                }
                else if (contractingOfficersName.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.ContractingOfficersName.StartsWith(criteria));
                }
                else
                {
                    predicate =
                        predicate.And(
                            wf =>
                            wf.UnliquidatedObligation.ContractingOfficersName.Trim() ==
                            criteria);
                }
            }

            if (currentlyAssignedTo != null)
            {
                hasFilters = true;
                var criteria = currentlyAssignedTo.Replace(Wildcard, "");
                if (currentlyAssignedTo.StartsWith(Wildcard) && currentlyAssignedTo.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.AspNetUser.UserName.Contains(criteria));
                }
                else if (currentlyAssignedTo.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.AspNetUser.UserName.Trim().EndsWith(criteria));
                }
                else if (currentlyAssignedTo.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.AspNetUser.UserName.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate = predicate.And(wf => wf.AspNetUser.UserName.Trim() == currentlyAssignedTo);
                }
            }

            if (hasBeenAssignedTo != null)
            {
                hasFilters = true;
                var criteria = hasBeenAssignedTo.Replace(Wildcard, "");
                if (hasBeenAssignedTo.StartsWith(Wildcard) && hasBeenAssignedTo.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.WorkflowHistories.Any(wfh => wfh.AspNetUser.UserName.Contains(criteria)));
                }
                else if (hasBeenAssignedTo.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.WorkflowHistories.Any(wfh => wfh.AspNetUser.UserName.EndsWith(criteria)));
                }
                else if (hasBeenAssignedTo.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.WorkflowHistories.Any(wfh => wfh.AspNetUser.UserName.StartsWith(criteria)));
                }
                else
                {
                    predicate =
                        predicate.And(
                            wf => wf.WorkflowHistories.Any(wfh => wfh.AspNetUser.UserName == criteria));
                }
            }

            if (awardNumber != null)
            {
                hasFilters = true;
                var criteria = awardNumber.Replace(Wildcard, "");
                if (awardNumber.StartsWith(Wildcard) && awardNumber.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.AwardNbr.Contains(criteria));
                }
                else if (awardNumber.StartsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.AwardNbr.Trim().EndsWith(criteria));
                }
                else if (awardNumber.EndsWith(Wildcard))
                {
                    predicate =
                        predicate.And(
                            wf => wf.UnliquidatedObligation.AwardNbr.Trim().StartsWith(criteria));
                }
                else
                {
                    predicate = predicate.And(wf => wf.UnliquidatedObligation.AwardNbr.Trim() == criteria);
                }
            }

            if (reasonIncludedInReview != null && reasonIncludedInReview.Count > 0)
            {
                hasFilters = true;
                predicate  = predicate.And(wf => reasonIncludedInReview.Contains(wf.UnliquidatedObligation.ReasonIncludedInReview.Trim()));
            }

            if (valid != null && valid.Count == 1)
            {
                hasFilters = true;
                var v = valid[0];
                predicate = predicate.And(wf => wf.UnliquidatedObligation.Valid == v);
            }

            if (status != null && status.Count > 0)
            {
                hasFilters = true;
                predicate  = predicate.And(wf => status.Contains(wf.UnliquidatedObligation.Status.Trim()));
            }

            if (reviewId != null && reviewId.Count > 0)
            {
                hasFilters = true;
                predicate  = predicate.And(wf => reviewId.Contains(wf.UnliquidatedObligation.ReviewId));
            }

            if (reassignableByMe.GetValueOrDefault())
            {
                hasFilters = true;
                var regionIds = GetUserGroupRegions(currentUser, PortalHelpers.ReassignGroupUserId);
                predicate = predicate.And(GetWorkflowsRegionIdPredicate(regionIds));
            }

            return(hasFilters ? predicate : null);
        }