コード例 #1
0
        public static IEnumerable <NamesInfo> Names2(string q, int limit)
        {
            var qp = FindNames(q);

            var rp = from p in qp
                     let spouse = DbUtil.Db.People.SingleOrDefault(ss =>
                                                                   ss.PeopleId == p.SpouseId &&
                                                                   ss.ContributionOptionsId == StatementOptionCode.Joint &&
                                                                   p.ContributionOptionsId == StatementOptionCode.Joint)
                                  orderby p.Name2
                                  select new NamesInfo
            {
                Pid     = p.PeopleId,
                name    = p.Name2,
                age     = p.Age,
                email   = p.EmailAddress,
                spouse  = spouse.Name,
                addr    = p.PrimaryAddress ?? "",
                altname = p.AltName,
                recent  = (from c in p.Contributions
                           where c.ContributionStatusId == 0
                           orderby c.ContributionDate descending
                           select new RecentContribution
                {
                    Amount = c.ContributionAmount,
                    DateGiven = c.ContributionDate,
                    CheckNo = c.CheckNo
                }).Take(4).ToList(),
                pledgesSummary = PledgesHelper.GetFilteredPledgesSummary(DbUtil.Db, p.PeopleId)
            };

            return(rp.Take(limit));
        }
コード例 #2
0
        public void Should_GetFilteredPledgesSummary()
        {
            using (var db = CMSDataContext.Create(DatabaseFixture.Host))
            {
                var fromDate     = new DateTime(2019, 1, 1);
                var person       = MockPeople.CreateSavePerson(db);
                var bundleHeader = MockContributions.CreateSaveBundle(db);
                var pledge       = MockContributions.CreateSaveContribution(
                    db, bundleHeader, fromDate, 200, peopleId: person.PeopleId, fundId: 1, contributionType: ContributionTypeCode.Pledge);
                var firstContribution  = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 100, peopleId: person.PeopleId, fundId: 1, contributionType: ContributionTypeCode.CheckCash);
                var secondContribution = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 100, peopleId: person.PeopleId, fundId: 2, contributionType: ContributionTypeCode.CheckCash);
                var setting            = MockSettings.CreateSaveSetting(db, "PostContributionPledgeFunds", "1");
                var expected           = MockContributions.FilteredPledgesSummary();

                var actual = PledgesHelper.GetFilteredPledgesSummary(db, person.PeopleId);
                actual.Should().BeEquivalentTo(expected);

                MockContributions.DeleteAllFromBundle(db, bundleHeader);
            }
        }
コード例 #3
0
        public void Should_GetFilteredPledgesSummary(decimal pledged, decimal contributed)
        {
            using (var db = CMSDataContext.Create(DatabaseFixture.Host))
            {
                var fromDate     = new DateTime(2019, 1, 1);
                var fund         = MockFunds.CreateSaveFund(db, true);
                var bundleHeader = MockContributions.CreateSaveBundle(db);
                var pledge       = MockContributions.CreateSaveContribution(
                    db, bundleHeader, fromDate, pledged, peopleId: 1, fundId: fund.FundId, contributionType: ContributionTypeCode.Pledge);
                MockSettings.CreateSaveSetting(db, "PostContributionPledgeFunds", fund.FundId.ToString());
                var firstContribution  = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, contributed, peopleId: 1, fundId: fund.FundId, contributionType: ContributionTypeCode.CheckCash);
                var secondContribution = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 100, peopleId: 1, fundId: 2, contributionType: ContributionTypeCode.CheckCash);

                var expected = MockContributions.CustomFilteredPledgesSummary(fund.FundId, fund.FundName, contributed, pledged);
                var actual   = PledgesHelper.GetFilteredPledgesSummary(db, 1);
                actual.Should().BeEquivalentTo(expected);

                MockSettings.CreateSaveSetting(db, "PostContributionPledgeFunds", "1");
                MockContributions.DeleteAllFromBundle(db, bundleHeader);
                MockFunds.DeleteFund(db, fund.FundId);
            }
        }
コード例 #4
0
        public object GetNamePidFromId()
        {
            IEnumerable <object> q;

            if (!string.IsNullOrEmpty(pid) && (pid[0] == 'e' || pid[0] == '-'))
            {
                var env = pid.Substring(1).ToInt();
                q = from e in DbUtil.Db.PeopleExtras
                    where e.Field == "EnvelopeNumber"
                    where e.IntValue == env
                    orderby e.Person.Family.HeadOfHouseholdId == e.PeopleId ? 1 : 2
                    select new
                {
                    e.PeopleId,
                    name           = e.Person.Name2 + (e.Person.DeceasedDate.HasValue ? "[DECEASED]" : ""),
                    pledgesSummary = PledgesHelper.GetFilteredPledgesSummary(DbUtil.Db, pid.ToInt())
                };
            }
            else
            {
                q = from i in DbUtil.Db.People
                    where i.PeopleId == pid.ToInt()
                    select new
                {
                    i.PeopleId,
                    name           = i.Name2 + (i.DeceasedDate.HasValue ? "[DECEASED]" : ""),
                    pledgesSummary = PledgesHelper.GetFilteredPledgesSummary(DbUtil.Db, pid.ToInt())
                };
            }
            var o = q.FirstOrDefault();

            if (o == null)
            {
                return(new { error = "not found" });
            }

            return(o);
        }
コード例 #5
0
        public static IEnumerable <NamesInfo> Names(string q, int limit)
        {
            var qp = FindNames(q);

            var rp = from p in qp
                     let spouse = DbUtil.Db.People.SingleOrDefault(ss =>
                                                                   ss.PeopleId == p.SpouseId &&
                                                                   ss.ContributionOptionsId == StatementOptionCode.Joint &&
                                                                   p.ContributionOptionsId == StatementOptionCode.Joint)
                                  orderby p.Name2
                                  select new NamesInfo
            {
                Pid            = p.PeopleId,
                name           = p.Name2,
                age            = p.Age,
                spouse         = spouse.Name,
                addr           = p.PrimaryAddress ?? "",
                altname        = p.AltName,
                pledgesSummary = PledgesHelper.GetFilteredPledgesSummary(DbUtil.Db, p.PeopleId)
            };

            return(rp.Take(limit));
        }
コード例 #6
0
        public void PledgesSummaryByFundListTest(List <PledgesSummary> pledgesSummary, List <int> fundIdList, List <PledgesSummary> expected)
        {
            var actual = PledgesHelper.PledgesSummaryByFundList(pledgesSummary, fundIdList);

            actual.Should().BeEquivalentTo(expected);
        }
コード例 #7
0
        public void GetFundIdListFromStringTest(string stringFunds, List <int> expected)
        {
            var actual = PledgesHelper.GetFundIdListFromString(stringFunds);

            actual.ShouldBe(expected);
        }