private IQueryable <Contribution> GetContributionRecords() { var currentUser = CurrentDatabase.CurrentUserPerson; var isFinanceUser = CurrentDatabase.CurrentRoles().Contains("Finance"); var isCurrentUser = currentUser.PeopleId == Person.PeopleId; var isSpouse = currentUser.PeopleId == Person.SpouseId; var isFamilyMember = currentUser.FamilyId == Person.FamilyId; if (isCurrentUser || (isSpouse && (Person.ContributionOptionsId ?? StatementOptionCode.Joint) == StatementOptionCode.Joint) || isFamilyMember || isFinanceUser) { return(from c in CurrentDatabase.Contributions where (c.PeopleId == Person.PeopleId || (c.PeopleId == Person.SpouseId && (Person.ContributionOptionsId ?? StatementOptionCode.Joint) == StatementOptionCode.Joint)) && c.ContributionStatusId == ContributionStatusCode.Recorded && !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) select c); } else { return(from c in CurrentDatabase.Contributions join f in CurrentDatabase.ContributionFunds.ScopedByRoleMembership(CurrentDatabase) on c.FundId equals f.FundId where c.PeopleId == Person.PeopleId && c.ContributionStatusId == ContributionStatusCode.Recorded && !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) select c); } }
public IEnumerable <SelectListItem> Organizations2() { int divId = (TargetDivId == 0) ? SourceDivId : TargetDivId; var member = MemberTypeCode.Member; var roles = CurrentDatabase.CurrentRoles(); var q = from o in CurrentDatabase.Organizations where o.LimitToRole == null || roles.Contains(o.LimitToRole) where o.DivOrgs.Any(di => di.DivId == divId) where o.OrganizationStatusId == OrgStatusCode.Active orderby o.OrganizationName let sctime = o.OrgSchedules.Count() == 1 ? " " + CurrentDatabase.GetScheduleDesc(o.OrgSchedules.First().MeetingTime) : "" let cmales = o.OrganizationMembers.Count(m => m.Person.GenderId == 1 && m.MemberTypeId == member) let cfemales = o.OrganizationMembers.Count(m => m.Person.GenderId == 2 && m.MemberTypeId == member) select new SelectListItem { Value = o.OrganizationId.ToString(), Text = o.OrganizationName + sctime + " (" + cmales + "+" + cfemales + "=" + (cmales + cfemales) + ")" }; var list = q.ToList(); list.Insert(0, new SelectListItem { Value = "0", Text = "(not specified)" }); return(list); }
override public IQueryable <Attend> DefineModelList() { var midnight = Util.Now.Date.AddDays(1); var roles = CurrentDatabase.CurrentRoles(); var q = from a in CurrentDatabase.Attends let org = a.Meeting.Organization where a.PeopleId == PeopleId where !(org.SecurityTypeId == 3 && Util2.OrgLeadersOnly) where org.LimitToRole == null || roles.Contains(org.LimitToRole) select a; if (!HttpContextFactory.Current.User.IsInRole("Admin") || HttpContextFactory.Current.Session["showallmeetings"] == null) { q = q.Where(a => a.EffAttendFlag == null || a.EffAttendFlag == true || a.Commitment != null); } if (Future) { q = q.Where(aa => aa.MeetingDate >= midnight); } else { q = q.Where(aa => aa.MeetingDate < midnight); } return(q); }
private bool ShowComments() { string limitToRole = CurrentDatabase.Setting("LimitRegistrationHistoryToRole", "false"); if (limitToRole == "false") { return(true); } else { return(CurrentDatabase.CurrentRoles().Contains(limitToRole)); } }
public IQueryable <InvolvementPreviou> DefineModelList(bool useOrgFilter) { var limitvisibility = Util2.OrgLeadersOnly || !HttpContextFactory.Current.User.IsInRole("Access"); var roles = CurrentDatabase.CurrentRoles(); return(from etd in CurrentDatabase.InvolvementPrevious(PeopleId, CurrentDatabase.UserId) where etd.TransactionStatus == false where etd.PeopleId == PeopleId where etd.TransactionTypeId >= 4 where !(limitvisibility && etd.SecurityTypeId == 3) where etd.LimitToRole == null || roles.Contains(etd.LimitToRole) where (!useOrgFilter || !OrgTypesFilter.Any() || OrgTypesFilter.Contains(etd.OrgType)) select etd); }
public IQueryable <InvolvementCurrent> DefineModelList(bool useOrgFilter) { var limitvisibility = Util2.OrgLeadersOnly || !HttpContextFactory.Current.User.IsInRole("Access"); var oids = new int[0]; if (Util2.OrgLeadersOnly) { oids = CurrentDatabase.GetLeaderOrgIds(Util.UserPeopleId); } var roles = CurrentDatabase.CurrentRoles(); return(from om in CurrentDatabase.InvolvementCurrent(PeopleId, Util.UserId) where (om.Pending ?? false) == false where oids.Contains(om.OrganizationId) || !(limitvisibility && om.SecurityTypeId == 3) where om.LimitToRole == null || roles.Contains(om.LimitToRole) where (!useOrgFilter || !OrgTypesFilter.Any() || OrgTypesFilter.Contains(om.OrgType)) select om); }
public IEnumerable <SelectListItem> Organizations() { var roles = CurrentDatabase.CurrentRoles(); var q = from o in CurrentDatabase.Organizations where o.LimitToRole == null || roles.Contains(o.LimitToRole) where o.DivOrgs.Any(di => di.DivId == SourceDivId) where o.OrganizationStatusId == OrgStatusCode.Active orderby o.OrganizationName let sctime = o.OrgSchedules.Count() == 1 ? " " + CurrentDatabase.GetScheduleDesc(o.OrgSchedules.First().MeetingTime) : "" select new SelectListItem { Value = o.OrganizationId.ToString(), Text = o.OrganizationName + sctime }; var list = q.ToList(); list.Insert(0, new SelectListItem { Value = "0", Text = "(not specified)" }); return(list); }
public override IQueryable <RegistrationList> DefineModelList() { var roles = CurrentDatabase.CurrentRoles(); var q = from r in CurrentDatabase.ViewRegistrationLists join org in CurrentDatabase.Organizations on r.OrganizationId equals org.OrganizationId where org.LimitToRole == null || roles.Contains(org.LimitToRole) where r.Cnt > 0 where r.First.Length > 0 && r.Last.Length > 0 select r; if (SearchParameters.Registrant.HasValue()) { string first; string last; Util.NameSplit(SearchParameters.Registrant, out first, out last); q = from c in q where first == null || first == "" || c.First.StartsWith(first) where last == null || last == "" || c.Last.StartsWith(last) select c; } if (SearchParameters.Organization.HasValue()) { if (SearchParameters.Organization.AllDigits()) { q = from c in q where c.OrganizationId == SearchParameters.Organization.ToInt() select c; } else { q = from c in q where c.OrganizationName.Contains(SearchParameters.Organization) select c; } } if (SearchParameters.Count.HasValue()) { var cnt = SearchParameters.Count.GetDigits().ToInt(); if (SearchParameters.Count.AllDigits()) { q = q.Where(cc => cc.Cnt == cnt); } else if (SearchParameters.Count.StartsWith(">=")) { q = q.Where(cc => cc.Cnt >= cnt); } else if (SearchParameters.Count.StartsWith(">")) { q = q.Where(cc => cc.Cnt > cnt); } else if (SearchParameters.Count.StartsWith("<=")) { q = q.Where(cc => cc.Cnt <= cnt); } else if (SearchParameters.Count.StartsWith("<")) { q = q.Where(cc => cc.Cnt < cnt); } } switch (SearchParameters.Complete.Value) { case "All": break; case "No": q = from r in q where (r.Completed ?? false) == false select r; break; case "Yes": q = from r in q where (r.Completed ?? false) select r; break; case "InProgress": q = from r in q let o = CurrentDatabase.Organizations.Single(oo => oo.OrganizationId == r.OrganizationId) where (r.Completed ?? false) select r; break; } switch (SearchParameters.Active.Value) { case "All": break; case "No": q = from r in q where (r.Expired ?? false) select r; break; case "Yes": q = from r in q where (r.Expired ?? false) == false select r; break; } switch (SearchParameters.Abandoned.Value) { case "Yes": q = from r in q where (r.Abandoned ?? false) select r; break; case "No": q = from r in q where (r.Abandoned ?? false) == false select r; break; } if (SearchParameters.FromMobileAppOnly) { q = from r in q where (r.Mobile == true) select r; } DateTime startDateRange; DateTime endDateRange; if (SearchParameters.StartDate.HasValue) { startDateRange = SearchParameters.StartDate.Value; if (SearchParameters.EndDate.HasValue) { endDateRange = SearchParameters.EndDate.Value.AddHours(+24); } else { endDateRange = DateTime.Today.AddHours(24); } } else if (SearchParameters.EndDate.HasValue) { startDateRange = DateTime.Parse("01/01/1800"); endDateRange = SearchParameters.EndDate.Value.AddHours(+24); } else { startDateRange = DateTime.Parse("01/01/1800"); endDateRange = Util.Now.Date.AddHours(+24); } q = from c in q where c.Stamp >= startDateRange && c.Stamp < endDateRange select c; return(q); }