Ejemplo n.º 1
0
        private IQueryable <CmsData.Organization> ApplySearch(IQueryable <CmsData.Organization> query)
        {
            if (Name.HasValue())
            {
                if (Name.AllDigits())
                {
                    query = from o in query
                            where o.OrganizationId == Name.ToInt()
                            select o;
                }
                else
                {
                    query = from o in query
                            where o.OrganizationName.Contains(Name) ||
                            o.LeaderName.Contains(Name) ||
                            o.Location.Contains(Name) ||
                            o.DivOrgs.Any(t => t.Division.Name.Contains(Name))
                            select o;
                }
            }
            if (DivId > 0)
            {
                query = from o in query
                        where o.DivOrgs.Any(t => t.DivId == DivId)
                        select o;
            }
            else if (ProgId > 0)
            {
                query = from o in query
                        where o.DivOrgs.Any(t => t.Division.ProgId == ProgId)
                        select o;
            }

            if (SchedId > 0)
            {
                query = from o in query
                        where o.OrgSchedules.Any(os => os.ScheduleId == SchedId)
                        select o;
            }

            if (StatusId > 0)
            {
                query = from o in query
                        where o.OrganizationStatusId == StatusId
                        select o;
            }

            if (CampusId > 0)
            {
                query = from o in query
                        where o.CampusId == CampusId
                        select o;
            }

            return(query);
        }
Ejemplo n.º 2
0
        public IQueryable <CmsData.Organization> FetchOrgs()
        {
            var me = Util.UserPeopleId;

            if (organizations != null)
            {
                return(organizations);
            }

            var u = DbUtil.Db.CurrentUser;

            var roles = u.UserRoles.Select(uu => uu.Role.RoleName).ToArray();

            organizations = from o in DbUtil.Db.Organizations
                            where o.LimitToRole == null || roles.Contains(o.LimitToRole)
                            select o;

            if (Util2.OrgMembersOnly)
            {
                organizations = from o in organizations
                                where o.OrganizationMembers.Any(om => om.PeopleId == Util.UserPeopleId)
                                select o;
            }
            else if (Util2.OrgLeadersOnly)
            {
                var oids = DbUtil.Db.GetLeaderOrgIds(Util.UserPeopleId);
                organizations = DbUtil.Db.Organizations.Where(o => oids.Contains(o.OrganizationId));
            }


            if (Name.HasValue())
            {
                if (Name.AllDigits())
                {
                    organizations = from o in organizations
                                    where o.OrganizationId == Name.ToInt() ||
                                    o.Location == Name ||
                                    o.PendingLoc == Name
                                    select o;
                }
                else
                {
                    organizations = from o in organizations
                                    where o.OrganizationName.Contains(Name) ||
                                    o.LeaderName.Contains(Name) ||
                                    o.Location == Name ||
                                    o.PendingLoc == Name ||
                                    o.DivOrgs.Any(t => t.Division.Name.Contains(Name))
                                    select o;
                }
            }
            if (DivisionId > 0)
            {
                organizations = from o in organizations
                                where o.DivOrgs.Any(t => t.DivId == DivisionId)
                                select o;
            }
            else if (ProgramId > 0)
            {
                organizations = from o in organizations
                                where o.DivOrgs.Any(d => d.Division.ProgDivs.Any(p => p.ProgId == ProgramId)) ||
                                o.Division.ProgId == ProgramId
                                select o;
            }

            if (ScheduleId > 0)
            {
                organizations = from o in organizations
                                where o.OrgSchedules.Any(os => os.ScheduleId == ScheduleId)
                                select o;
            }
            if (ScheduleId == -1)
            {
                organizations = from o in organizations
                                where o.OrgSchedules.Count() == 0
                                select o;
            }

            if (StatusId > 0)
            {
                organizations = from o in organizations
                                where o.OrganizationStatusId == StatusId
                                select o;
            }

            if (TypeId > 0)
            {
                organizations = from o in organizations
                                where o.OrganizationTypeId == TypeId
                                select o;
            }
            else if (TypeId == -1)
            {
                organizations = from o in organizations
                                where o.OrganizationTypeId == null
                                select o;
            }

            if (CampusId > 0)
            {
                organizations = from o in organizations
                                where o.CampusId == CampusId
                                select o;
            }
            else if (CampusId == -1)
            {
                organizations = from o in organizations
                                where o.CampusId == null
                                select o;
            }

            if (this.OnlineReg == 99)
            {
                organizations = from o in organizations
                                where o.RegistrationTypeId > 0
                                select o;
            }
            else if (this.OnlineReg > 0)
            {
                organizations = from o in organizations
                                where o.RegistrationTypeId == OnlineReg
                                select o;
            }
            else if (this.OnlineReg == 0)
            {
                organizations = from o in organizations
                                where (o.RegistrationTypeId ?? 0) == 0
                                select o;
            }

            if (MainFellowship == true)
            {
                organizations = from o in organizations
                                where o.IsBibleFellowshipOrg == true
                                select o;
            }

            if (ParentOrg == true)
            {
                organizations = from o in organizations
                                where o.ChildOrgs.Any()
                                select o;
            }

            return(organizations);
        }
Ejemplo n.º 3
0
        public IQueryable <CmsData.Organization> FetchOrgs()
        {
            var me = Util.UserPeopleId;

            if (organizations != null)
            {
                return(organizations);
            }

            var u = DbUtil.Db.CurrentUser;

            var roles = u.UserRoles.Select(uu => uu.Role.RoleName).ToArray();

            organizations = from o in DbUtil.Db.Organizations
                            where o.LimitToRole == null || roles.Contains(o.LimitToRole)
                            select o;

            if (Util2.OrgLeadersOnly)
            {
                var oids = DbUtil.Db.GetLeaderOrgIds(Util.UserPeopleId);
                organizations = DbUtil.Db.Organizations.Where(o => oids.Contains(o.OrganizationId));
            }

            if (Name.HasValue())
            {
                if (Name.AllDigits())
                {
                    organizations = from o in organizations
                                    where o.OrganizationId == Name.ToInt()
                                    select o;
                }
                else if (Name.ToInt() < 0)
                {
                    var loc = Name.GetDigits();
                    organizations = from o in organizations
                                    where o.Location == loc
                                    select o;
                }
                else
                {
                    organizations = from o in organizations
                                    where o.OrganizationName.Contains(Name) ||
                                    o.LeaderName.Contains(Name) ||
                                    o.Location == Name ||
                                    o.PendingLoc == Name ||
                                    o.DivOrgs.Any(t => t.Division.Name.Contains(Name))
                                    select o;
                }
            }
            if (DivisionId > 0)
            {
                organizations = from o in organizations
                                where o.DivOrgs.Any(t => t.DivId == DivisionId)
                                select o;
            }
            else if (ProgramId > 0)
            {
                if (FromWeekAtAGlance)
                {
                    organizations = from o in organizations
                                    where o.DivOrgs.Any(d => d.Division.ProgDivs.Any(p => p.ProgId == ProgramId &&
                                                                                     p.Division.ReportLine > 0)) ||
                                    (o.Division.ProgId == ProgramId && o.Division.ReportLine > 0)
                                    select o;
                }
                else
                {
                    organizations = from o in organizations
                                    where o.DivOrgs.Any(d => d.Division.ProgDivs.Any(p => p.ProgId == ProgramId)) ||
                                    o.Division.ProgId == ProgramId
                                    select o;
                }
            }

            if (ScheduleId > 0)
            {
                organizations = from o in organizations
                                where o.OrgSchedules.Any(os => os.ScheduleId == ScheduleId)
                                select o;
            }
            if (ScheduleId == -1)
            {
                organizations = from o in organizations
                                where !o.OrgSchedules.Any()
                                select o;
            }

            if (StatusId > 0)
            {
                organizations = from o in organizations
                                where o.OrganizationStatusId == StatusId
                                select o;
            }

            if (TypeId > 0)
            {
                organizations = from o in organizations
                                where o.OrganizationTypeId == TypeId
                                select o;
            }
            else if (TypeId == OrgType.NoOrgType)
            {
                organizations = from o in organizations
                                where o.OrganizationTypeId == null
                                select o;
            }
            else if (TypeId == OrgType.MainFellowship)
            {
                organizations = from o in organizations
                                where o.IsBibleFellowshipOrg == true
                                select o;
            }
            else if (TypeId == OrgType.NotMainFellowship)
            {
                organizations = from o in organizations
                                where (o.IsBibleFellowshipOrg ?? false) == false
                                select o;
            }
            else if (TypeId == OrgType.SuspendedCheckin)
            {
                organizations = from o in organizations
                                where (o.SuspendCheckin ?? false)
                                select o;
            }
            else if (TypeId == OrgType.ParentOrg)
            {
                organizations = from o in organizations
                                where o.ChildOrgs.Any()
                                select o;
            }
            else if (TypeId == OrgType.ChildOrg)
            {
                organizations = from o in organizations
                                where o.ParentOrgId != null
                                select o;
            }
            else if (TypeId == OrgType.Fees)
            {
                organizations = from o in organizations
                                join f in DbUtil.Db.ViewOrgsWithFees on o.OrganizationId equals f.OrganizationId
                                select o;
            }
            else if (TypeId == OrgType.NoFees)
            {
                organizations = from o in organizations
                                join f in DbUtil.Db.ViewOrgsWithoutFees on o.OrganizationId equals f.OrganizationId
                                select o;
            }


            if (CampusId > 0)
            {
                organizations = from o in organizations
                                where o.CampusId == CampusId
                                select o;
            }
            else if (CampusId == -1)
            {
                organizations = from o in organizations
                                where o.CampusId == null
                                select o;
            }

            if (OnlineReg == RegistrationClassification.AnyOnlineReg99)
            {
                organizations = from o in organizations
                                where o.RegistrationTypeId > 0
                                select o;
            }
            else if (OnlineReg == RegistrationClassification.AnyOnlineRegMissionTrip98)
            {
                organizations = from o in organizations
                                where o.RegistrationTypeId > 0 && o.IsMissionTrip == true
                                select o;
            }
            else if (OnlineReg == RegistrationClassification.AnyOnlineRegNonPicklist97)
            {
                organizations = from o in organizations
                                join p in DbUtil.Db.ViewMasterOrgs on o.OrganizationId equals p.PickListOrgId into j
                                from p in j.DefaultIfEmpty()
                                where p.PickListOrgId == null
                                where o.RegistrationTypeId > 0
                                select o;
            }
            else if (OnlineReg == RegistrationClassification.AnyOnlineRegActive96)
            {
                organizations = from o in organizations
                                join a in DbUtil.Db.ViewActiveRegistrations on o.OrganizationId equals a.OrganizationId
                                select o;
            }
            else if (OnlineReg == RegistrationClassification.AnyOnlineRegNotOnApp95)
            {
                organizations = from o in organizations
                                join ac in DbUtil.Db.ViewActiveRegistrations on o.OrganizationId equals ac.OrganizationId
                                where DbUtil.Db.ViewAppRegistrations.All(ap => ap.OrganizationId != o.OrganizationId)
                                select o;
            }
            else if (OnlineReg == RegistrationClassification.AnyOnlineRegOnApp94)
            {
                organizations = from o in organizations
                                join a in DbUtil.Db.ViewAppRegistrations on o.OrganizationId equals a.OrganizationId
                                select o;
            }
            else if (OnlineReg > 0)
            {
                organizations = from o in organizations
                                where o.RegistrationTypeId == OnlineReg
                                select o;
            }
            else if (OnlineReg == 0)
            {
                organizations = from o in organizations
                                where (o.RegistrationTypeId ?? 0) == 0
                                select o;
            }

            return(organizations);
        }
Ejemplo n.º 4
0
        public IQueryable <CmsData.Organization> FetchOrgs()
        {
            var me = Util.UserPeopleId;

            if (organizations != null)
            {
                return(organizations);
            }

            var u = DbUtil.Db.CurrentUser;

            var roles = u.UserRoles.Select(uu => uu.Role.RoleName).ToArray();

            organizations = from o in DbUtil.Db.Organizations
                            where o.LimitToRole == null || roles.Contains(o.LimitToRole)
                            select o;

            if (Util2.OrgLeadersOnly)
            {
                var oids = DbUtil.Db.GetLeaderOrgIds(Util.UserPeopleId);
                organizations = DbUtil.Db.Organizations.Where(o => oids.Contains(o.OrganizationId));
            }

            if (Name.HasValue())
            {
                if (Name.AllDigits())
                {
                    organizations = from o in organizations
                                    where o.OrganizationId == Name.ToInt()
                                    select o;
                }
                else if (Name.ToInt() < 0)
                {
                    var loc = Name.GetDigits();
                    organizations = from o in organizations
                                    where o.Location == loc
                                    select o;
                }
                else
                {
                    organizations = from o in organizations
                                    where o.OrganizationName.Contains(Name) ||
                                    o.LeaderName.Contains(Name) ||
                                    o.Location == Name ||
                                    o.PendingLoc == Name ||
                                    o.DivOrgs.Any(t => t.Division.Name.Contains(Name))
                                    select o;
                }
            }
            if (DivisionId > 0)
            {
                organizations = from o in organizations
                                where o.DivOrgs.Any(t => t.DivId == DivisionId)
                                select o;
            }
            else if (ProgramId > 0)
            {
                if (FromWeekAtAGlance)
                {
                    organizations = from o in organizations
                                    where o.DivOrgs.Any(d => d.Division.ProgDivs.Any(p => p.ProgId == ProgramId &&
                                                                                     p.Division.ReportLine > 0)) ||
                                    (o.Division.ProgId == ProgramId && o.Division.ReportLine > 0)
                                    select o;
                }
                else
                {
                    organizations = from o in organizations
                                    where o.DivOrgs.Any(d => d.Division.ProgDivs.Any(p => p.ProgId == ProgramId)) ||
                                    o.Division.ProgId == ProgramId
                                    select o;
                }
            }

            if (ScheduleId > 0)
            {
                organizations = from o in organizations
                                where o.OrgSchedules.Any(os => os.ScheduleId == ScheduleId)
                                select o;
            }
            if (ScheduleId == -1)
            {
                organizations = from o in organizations
                                where !o.OrgSchedules.Any()
                                select o;
            }

            if (StatusId > 0)
            {
                organizations = from o in organizations
                                where o.OrganizationStatusId == StatusId
                                select o;
            }

            if (TypeId > 0)
            {
                organizations = from o in organizations
                                where o.OrganizationTypeId == TypeId
                                select o;
            }
            else if (TypeId == OrgType.NoOrgType)
            {
                organizations = from o in organizations
                                where o.OrganizationTypeId == null
                                select o;
            }
            else if (TypeId == OrgType.MainFellowship)
            {
                organizations = from o in organizations
                                where o.IsBibleFellowshipOrg == true
                                select o;
            }
            else if (TypeId == OrgType.NotMainFellowship)
            {
                organizations = from o in organizations
                                where (o.IsBibleFellowshipOrg ?? false) == false
                                select o;
            }
            else if (TypeId == OrgType.SuspendedCheckin)
            {
                organizations = from o in organizations
                                where (o.SuspendCheckin ?? false)
                                select o;
            }
            else if (TypeId == OrgType.ParentOrg)
            {
                organizations = from o in organizations
                                where o.ChildOrgs.Any()
                                select o;
            }
            else if (TypeId == OrgType.ChildOrg)
            {
                organizations = from o in organizations
                                where o.ParentOrgId != null
                                select o;
            }


            if (CampusId > 0)
            {
                organizations = from o in organizations
                                where o.CampusId == CampusId
                                select o;
            }
            else if (CampusId == -1)
            {
                organizations = from o in organizations
                                where o.CampusId == null
                                select o;
            }

            if (OnlineReg == 99)
            {
                organizations = from o in organizations
                                where o.RegistrationTypeId > 0
                                select o;
            }
            else if (OnlineReg == 98)
            {
                organizations = from o in organizations
                                where o.RegistrationTypeId > 0 && o.IsMissionTrip == true
                                select o;
            }
            else if (OnlineReg > 0)
            {
                organizations = from o in organizations
                                where o.RegistrationTypeId == OnlineReg
                                select o;
            }
            else if (OnlineReg == 0)
            {
                organizations = from o in organizations
                                where (o.RegistrationTypeId ?? 0) == 0
                                select o;
            }

            return(organizations);
        }
Ejemplo n.º 5
0
        public override IQueryable <Person> DefineModelList()
        {
            if (ShowLimitedSearch)
            {
                return(RunLimitedSearch());
            }

            //var db = Db;
            var q = Util2.OrgLeadersOnly
                ? CurrentDatabase.OrgLeadersOnlyTag2().People(CurrentDatabase)
                : CurrentDatabase.People.AsQueryable();

            if (UsersOnly)
            {
                q = q.Where(p => p.Users.Any(uu => uu.UserRoles.Any(ur => ur.Role.RoleName == "Access")));
            }

            if (OnlineRegTypeSearch)
            {
                return(from pid in CurrentDatabase.FindPerson(FirstName, LastName, dob.ToDate(), Email, Phone)
                       join p in q on pid.PeopleId equals p.PeopleId
                       select p);
            }

            if (Name.HasValue())
            {
                string first, last;
                Util.NameSplit(Name, out first, out last);

                if (Name.AllDigits())
                {
                    q = from p in q
                        where p.PeopleId == Name.ToInt()
                        select p;
                }
                else
                {
                    if (first.HasValue() || last.HasValue())
                    {
                        q = from p in q
                            where p.LastName.StartsWith(last) || p.MaidenName.StartsWith(last) || p.AltName.StartsWith(last)
                            where
                            p.FirstName.StartsWith(first) || p.NickName.StartsWith(first) || p.MiddleName.StartsWith(first)
                            select p;
                    }
                    else
                    {
                        q = CurrentDatabase.Setting("UseAltnameContains")
                            ? from p in q
                            where p.LastName.StartsWith(Name) || p.MaidenName.StartsWith(Name) || p.AltName.Contains(Name) ||
                            p.FirstName.StartsWith(Name) || p.NickName.StartsWith(Name) || p.MiddleName.StartsWith(Name)
                            select p
                            : from p in q
                            where p.LastName.StartsWith(Name) || p.MaidenName.StartsWith(Name) || p.AltName.StartsWith(Name) ||
                            p.FirstName.StartsWith(Name) || p.NickName.StartsWith(Name) || p.MiddleName.StartsWith(Name)
                            select p;
                    }
                }
            }

            if (Address.IsNotNull())
            {
                Address = Address.Trim();
                if (Address.HasValue())
                {
                    q = from p in q
                        where p.Family.AddressLineOne.Contains(Address) ||
                        p.Family.AddressLineTwo.Contains(Address) ||
                        p.Family.CityName.Contains(Address) ||
                        p.Family.ZipCode.Contains(Address)
                        select p;
                }
            }
            if (Communication.IsNotNull())
            {
                Communication = Communication.Trim();
                if (Communication.HasValue())
                {
                    q = from p in q
                        where p.CellPhone.Contains(Communication) || p.EmailAddress.Contains(Communication) ||
                        p.Family.HomePhone.Contains(Communication) ||
                        p.WorkPhone.Contains(Communication)
                        select p;
                }
            }
            if (dob.HasValue())
            {
                DateTime dt;
                if (DateTime.TryParse(dob, out dt))
                {
                    if (Regex.IsMatch(dob, @"\d+/\d+/\d+"))
                    {
                        q = q.Where(p => p.BirthDay == dt.Day && p.BirthMonth == dt.Month && p.BirthYear == dt.Year);
                    }
                    else
                    {
                        q = q.Where(p => p.BirthDay == dt.Day && p.BirthMonth == dt.Month);
                    }
                }
                else
                {
                    int n;
                    if (int.TryParse(dob, out n))
                    {
                        if (n >= 1 && n <= 12)
                        {
                            q = q.Where(p => p.BirthMonth == n);
                        }
                        else
                        {
                            q = q.Where(p => p.BirthYear == n);
                        }
                    }
                }
            }
            return(q);
        }