예제 #1
0
        public IQueryable <OrgSearch> FetchOrgs()
        {
            var queryable = DbUtil.Db.OrgSearch(Name, ProgramId, DivisionId, TypeId, CampusId, ScheduleId, StatusId, OnlineReg,
                                                DbUtil.Db.CurrentUser.UserId, TagDiv);

            if (ExtraValuesDict != null && ExtraValuesDict.Any())
            {
                var orgIds = queryable.Select(x => x.OrganizationId).ToList();

                foreach (var ev in ExtraValuesDict)
                {
                    orgIds = DbUtil.Db.OrganizationExtras
                             .Where(x => orgIds.Contains(x.OrganizationId) && x.Field == ev.Key &&
                                    (
                                        x.StrValue.ToLower().Contains(ev.Value) ||
                                        x.Data.ToLower().Contains(ev.Value)) ||
                                    x.DateValue != null && x.DateValue.ToString().Contains(ev.Value) ||
                                    x.IntValue != null && x.IntValue.ToString().Contains(ev.Value) ||
                                    x.BitValue != null && x.BitValue.ToString().Contains(ev.Value)
                                    )
                             .Select(x => x.OrganizationId).ToList();
                }

                queryable = queryable.Where(x => orgIds.Contains(x.OrganizationId));
            }

            return(queryable);
        }
예제 #2
0
        public IQueryable <OrgSearch> FetchOrgs()
        {
            IQueryable <OrgSearch> queryable = null;

            if (CampusId == -1)
            {
                queryable = CurrentDatabase.OrgSearch(Name, ProgramId, DivisionId, TypeId, 0, ScheduleId, StatusId, OnlineReg,
                                                      CurrentDatabase.CurrentUser.UserId, TagDiv).Where(x => x.Campus == null);
            }
            else
            {
                queryable = CurrentDatabase.OrgSearch(Name, ProgramId, DivisionId, TypeId, CampusId, ScheduleId, StatusId, OnlineReg,
                                                      CurrentDatabase.CurrentUser.UserId, TagDiv);
            }

            if (ExtraValuesDict != null && ExtraValuesDict.Any())
            {
                var orgIds = queryable.Select(x => x.OrganizationId).ToList();

                foreach (var ev in ExtraValuesDict)
                {
                    orgIds = CurrentDatabase.OrganizationExtras
                             .Where(x => orgIds.Contains(x.OrganizationId) && x.Field == ev.Key &&
                                    (
                                        x.Type.Equals("Code") ? x.StrValue.ToLower().Equals(ev.Value) : x.StrValue.ToLower().Contains(ev.Value) ||
                                        x.Type.Equals("Code") ? x.Data.ToLower().Equals(ev.Value) : x.Data.ToLower().Contains(ev.Value)) ||
                                    x.DateValue != null && x.DateValue.ToString().Contains(ev.Value) ||
                                    x.IntValue != null && x.IntValue.ToString().Contains(ev.Value) ||
                                    x.BitValue != null && x.BitValue.ToString().Contains(ev.Value)
                                    )
                             .Select(x => x.OrganizationId).ToList();
                }

                queryable = queryable.Where(x => orgIds.Contains(x.OrganizationId));
            }

            return(queryable);
        }