Пример #1
0
 public IEnumerable<RangeInfo> GetTotalsByFundRange()
 {
     var model = new BundleModel();
     var rangeInfos = model.TotalsByFundRange(FundId, Dt1.GetValueOrDefault(), Dt2.GetValueOrDefault(), string.IsNullOrWhiteSpace(Pledged) ? "false" : Pledged, CampusId);
     RangeTotal = model.RangeTotal;
     return rangeInfos;
 }
Пример #2
0
 public IEnumerable<AgeRangeInfo> GetTotalsByFundAgeRange()
 {
     var model = new BundleModel();
     var ageRangeInfos = model.TotalsByFundAgeRange(0, Dt1.GetValueOrDefault(), Dt2.GetValueOrDefault(), string.Empty, CampusId);
     RangeTotal = model.RangeTotal;
     return ageRangeInfos;
 }
Пример #3
0
        public IEnumerable <RangeInfo> GetTotalsByFundRange()
        {
            var list = (from r in DbUtil.Db.GetContributionsRange(Dt1, Dt2, CampusId, false, true, Pledged)
                        orderby r.Range
                        select r).ToList();

            RangeTotal = new RangeInfo
            {
                Total      = list.Sum(vv => vv.Total ?? 0),
                Count      = list.Sum(vv => vv.Count ?? 0),
                DonorCount = list.Sum(vv => vv.DonorCount ?? 0),
            };
            var list2 = from r in list
                        select new RangeInfo
            {
                RangeId    = r.Range,
                Total      = r.Total ?? 0,
                Count      = r.Count ?? 0,
                DonorCount = r.DonorCount ?? 0,
                PctCount   = (r.Count ?? 0) / Convert.ToDecimal(RangeTotal.Count) * 100,
                PctTotal   = (r.Total ?? 0) / RangeTotal.Total * 100,
            };

            return(list2);
        }
        public IEnumerable <AgeRangeInfo> GetTotalsByFundAgeRange()
        {
            var model         = new BundleModel();
            var ageRangeInfos = model.TotalsByFundAgeRange(0, Dt1.GetValueOrDefault(), Dt2.GetValueOrDefault(), string.Empty, CampusId);

            RangeTotal = model.RangeTotal;
            return(ageRangeInfos);
        }
Пример #5
0
        public IEnumerable <RangeInfo> GetTotalsByFundRange()
        {
            var model      = new BundleModel();
            var rangeInfos = model.TotalsByFundRange(FundId, Dt1.GetValueOrDefault(), Dt2.GetValueOrDefault(), string.IsNullOrWhiteSpace(Pledged) ? "false" : Pledged, CampusId);

            RangeTotal = model.RangeTotal;
            return(rangeInfos);
        }
        public IEnumerable <AgeRangeInfo> GetTotalsByFundAgeRange()
        {
            var model         = new BundleModel();
            var fundids       = APIContributionSearchModel.GetCustomFundSetList(DbUtil.Db, FundSet).JoinInts(",");
            var ageRangeInfos = model.TotalsByFundAgeRange(0, Dt1.GetValueOrDefault(), Dt2.GetValueOrDefault(), string.Empty, CampusId, fundids);

            RangeTotal = model.RangeTotal;
            return(ageRangeInfos);
        }
        public IEnumerable <AgeRangeInfo> GetTotalsByFundAgeRange()
        {
            var model             = new BundleModel();
            var customFundIds     = APIContributionSearchModel.GetCustomFundSetList(DbUtil.Db, FundSet);
            var authorizedFundIds = DbUtil.Db.ContributionFunds.ScopedByRoleMembership(DbUtil.Db).Select(f => f.FundId).ToList();

            string fundIds = string.Empty;

            if (customFundIds?.Count > 0)
            {
                fundIds = authorizedFundIds.Where(f => customFundIds.Contains(f)).JoinInts(",");
            }
            else
            {
                fundIds = authorizedFundIds.JoinInts(",");
            }

            var ageRangeInfos = model.TotalsByFundAgeRange(0, Dt1.GetValueOrDefault(), Dt2.GetValueOrDefault(), string.Empty, CampusId, fundIds);

            RangeTotal = model.RangeTotal;
            return(ageRangeInfos);
        }
Пример #8
0
        public IEnumerable <RangeInfo> GetTotalsByFundRange()
        {
            var customFundIds     = APIContributionSearchModel.GetCustomFundSetList(DbUtil.Db, FundSet);
            var authorizedFundIds = DbUtil.Db.ContributionFunds.ScopedByRoleMembership().Select(f => f.FundId).ToList();

            string fundIds = string.Empty;

            if (customFundIds?.Count > 0)
            {
                fundIds = authorizedFundIds.Where(f => customFundIds.Contains(f)).JoinInts(",");
            }
            else
            {
                fundIds = authorizedFundIds.JoinInts(",");
            }

            var list = (from r in DbUtil.Db.GetContributionsRange(Dt1, Dt2, CampusId, false, true, Pledged, FundId, fundIds)
                        orderby r.Range
                        select r).ToList();

            RangeTotal = new RangeInfo
            {
                Total      = list.Sum(vv => vv.Total ?? 0),
                Count      = list.Sum(vv => vv.Count ?? 0),
                DonorCount = list.Sum(vv => vv.DonorCount ?? 0),
            };
            var list2 = from r in list
                        select new RangeInfo
            {
                RangeId    = r.Range,
                Total      = r.Total ?? 0,
                Count      = r.Count ?? 0,
                DonorCount = r.DonorCount ?? 0,
                PctCount   = (r.Count ?? 0) / Convert.ToDecimal(RangeTotal.Count) * 100,
                PctTotal   = (r.Total ?? 0) / RangeTotal.Total * 100,
            };

            return(list2);
        }
Пример #9
0
 public IEnumerable<RangeInfo> GetTotalsByFundRange()
 {
     var list = (from r in DbUtil.Db.GetContributionsRange(Dt1, Dt2, CampusId, false, true, Pledged)
                 orderby r.Range
                 select r).ToList();
     RangeTotal = new RangeInfo
     {
         Total = list.Sum(vv => vv.Total ?? 0),
         Count = list.Sum(vv => vv.Count ?? 0),
         DonorCount = list.Sum(vv => vv.DonorCount ?? 0),
     };
     var list2 = from r in list
                 select new RangeInfo
                 {
                     RangeId = r.Range,
                     Total = r.Total ?? 0,
                     Count = r.Count ?? 0,
                     DonorCount = r.DonorCount ?? 0,
                     PctCount = (r.Count ?? 0) / Convert.ToDecimal(RangeTotal.Count) * 100,
                     PctTotal = (r.Total ?? 0) / RangeTotal.Total * 100,
                 };
     return list2;
 }
Пример #10
0
        public IEnumerable <AgeRangeInfo> TotalsByFundAgeRange(int fundid, DateTime dt1, DateTime dt2, string Pledges, int CampusId, string fundids)
        {
            var list1 = (from r in DbUtil.Db.GetTotalContributionsAgeRange(dt1, dt2, CampusId, null, true, fundids)
                         select new AgeRangeInfo()
            {
                Range = r.Range,
                Total = r.Total ?? 0,
                Count = r.Count ?? 0,
                DonorCount = r.DonorCount ?? 0,
            }).ToList();

            RangeTotal = new RangeInfo
            {
                Count      = list1.Sum(t => t.Count),
                Total      = list1.Sum(t => t.Total),
                DonorCount = list1.Sum(t => t.DonorCount)
            };
            var list = (from r in list1
                        select new AgeRangeInfo()
            {
                Range = r.Range,
                Total = r.Total,
                Count = r.Count,
                DonorCount = r.DonorCount,
                PctCount = (decimal)r.Count / RangeTotal.Count * 100,
                PctTotal = r.Total / RangeTotal.Total * 100
            }).ToList();

            return(list);
            //            var q0 = from c in DbUtil.Db.Contributions
            //                     where dt1 <= c.ContributionDate.Value.Date
            //                     where c.ContributionDate.Value.Date <= dt2
            //                     where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId)
            //                     where c.FundId == fundid || fundid == 0
            //                     where CampusId == 0 || c.Person.CampusId == CampusId
            //                     select c;
            //            switch (Pledges)
            //            {
            //                case "true":
            //                    q0 = from c in q0
            //                         where c.ContributionTypeId == ContributionTypeCode.Pledge
            //                         select c;
            //                    break;
            //                case "false":
            //                    q0 = from c in q0
            //                         where c.ContributionStatusId == ContributionStatusCode.Recorded
            //                         where c.ContributionTypeId != ContributionTypeCode.Pledge
            ////                         where c.PostingDate != null
            //                         select c;
            //                    break;
            //                case "both":
            //                    q0 = from c in q0
            //                         where (c.ContributionTypeId != ContributionTypeCode.Pledge && c.ContributionStatusId == ContributionStatusCode.Recorded)
            //                                || c.ContributionTypeId == ContributionTypeCode.Pledge
            //                         where (c.ContributionTypeId != ContributionTypeCode.Pledge && c.PostingDate != null)
            //                                || c.ContributionTypeId == ContributionTypeCode.Pledge
            //                         select c;
            //                    break;
            //            }
            //
            //            var q = from c in q0
            //                    let age = c.Person.Age ?? 0
            //                    let agerange = age == 0 ? 0 : (age / 10) + 1
            //                    group c by agerange into g
            //                    orderby g.Key
            //                    select new AgeRangeInfo
            //                    {
            //                        RangeId = g.Key,
            //                        Total = g.Sum(t => t.ContributionAmount),
            //                        Count = g.Count(),
            //                        DonorCount = (from d in g
            //                                      group d by d.PeopleId into gd
            //                                      select gd).Count()
            //                    };
            //            var q2 = from r in q
            //                     select new AgeRangeInfo
            //                     {
            //                         RangeId = r.RangeId,
            //                         Total = r.Total,
            //                         Count = r.Count,
            //                         DonorCount = r.DonorCount,
            //                         PctCount = (decimal)r.Count / RangeTotal.Count * 100,
            //                         PctTotal = r.Total.Value / RangeTotal.Total.Value * 100,
            //                     };
            //            return q2;
        }
Пример #11
0
        public IEnumerable <RangeInfo> TotalsByFundRange(int fundid, DateTime dt1, DateTime dt2, bool Pledges, int CampusId)
        {
            dt2 = dt2.AddDays(1);
            var q0 = from c in DbUtil.Db.Contributions
                     where dt1 <= c.ContributionDate.Value.Date
                     where c.ContributionDate.Value.Date < dt2
                     where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId)
                     where c.FundId == fundid || fundid == 0
                     where CampusId == 0 || c.CampusId == CampusId
                     select c;

            //            switch (Pledges)
            //            {
            //                case "true":
            //                    q0 = from c in q0
            //                         where c.ContributionTypeId == ContributionTypeCode.Pledge
            //                         select c;
            //                    break;
            //                case "false":
            //                    q0 = from c in q0
            //                         where c.ContributionStatusId == ContributionStatusCode.Recorded
            //                         where c.ContributionTypeId != ContributionTypeCode.Pledge
            //                         //where c.PostingDate != null
            //                         select c;
            //                    break;
            //                case "both":
            //                    q0 = from c in q0
            //                         where (c.ContributionTypeId != ContributionTypeCode.Pledge && c.ContributionStatusId == ContributionStatusCode.Recorded)
            //                                || c.ContributionTypeId == ContributionTypeCode.Pledge
            //                         where (c.ContributionTypeId != ContributionTypeCode.Pledge && c.PostingDate != null)
            //                                || c.ContributionTypeId == ContributionTypeCode.Pledge
            //                         select c;
            //                    break;
            //            }

            if (q0.Any())
            {
                var q = from c in q0
                        group c by DbUtil.Db.DollarRange(c.ContributionAmount) into g
                        orderby g.Key
                        select new RangeInfo
                {
                    RangeId    = g.Key.Value,
                    Total      = g.Sum(t => t.ContributionAmount) ?? 0,
                    Count      = g.Count(),
                    DonorCount = (from d in g
                                  group d by d.PeopleId into gd
                                  select gd).Count()
                };
                RangeTotal = new RangeInfo
                {
                    Count      = q.Sum(t => t.Count),
                    Total      = q.Sum(t => t.Total),
                    DonorCount = (from c in q0 group c by c.PeopleId into g select g).Count()
                };
                var q2 = from r in q
                         select new RangeInfo
                {
                    RangeId    = r.RangeId,
                    Total      = r.Total,
                    Count      = r.Count,
                    DonorCount = r.DonorCount,
                    PctCount   = (decimal)r.Count / RangeTotal.Count * 100,
                    PctTotal   = r.Total / RangeTotal.Total * 100,
                };
                return(q2);
            }
            return(new List <RangeInfo>());
        }
Пример #12
0
        public IEnumerable<RangeInfo> TotalsByFundRange(int fundid, DateTime dt1, DateTime dt2, string Pledges, int CampusId)
        {
            dt2 = dt2.AddDays(1);
            var q0 = from c in DbUtil.Db.Contributions
                     where dt1 <= c.ContributionDate.Value.Date
                     where c.ContributionDate.Value.Date < dt2
                     where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId)
                     where c.FundId == fundid || fundid == 0
                     where CampusId == 0 || c.Person.CampusId == CampusId
                     select c;
            switch (Pledges)
            {
                case "true":
                    q0 = from c in q0
                         where c.ContributionTypeId == ContributionTypeCode.Pledge
                         select c;
                    break;
                case "false":
                    q0 = from c in q0
                         where c.ContributionStatusId == ContributionStatusCode.Recorded
                         where c.ContributionTypeId != ContributionTypeCode.Pledge
                         //where c.PostingDate != null
                         select c;
                    break;
                case "both":
                    q0 = from c in q0
                         where (c.ContributionTypeId != ContributionTypeCode.Pledge && c.ContributionStatusId == ContributionStatusCode.Recorded)
                                || c.ContributionTypeId == ContributionTypeCode.Pledge
                         where (c.ContributionTypeId != ContributionTypeCode.Pledge && c.PostingDate != null)
                                || c.ContributionTypeId == ContributionTypeCode.Pledge
                         select c;
                    break;
            }

            var q = from c in q0
                    group c by DbUtil.Db.DollarRange(c.ContributionAmount) into g
                    orderby g.Key
                    select new RangeInfo
                    {
                        RangeId = g.Key.Value,
                        Total = g.Sum(t => t.ContributionAmount),
                        Count = g.Count(),
                        DonorCount = (from d in g
                                      group d by d.PeopleId into gd
                                      select gd).Count()
                    };
            RangeTotal = new RangeInfo
            {
                Count = q.Sum(t => t.Count),
                Total = q.Sum(t => t.Total),
                DonorCount = (from c in q0 group c by c.PeopleId into g select g).Count()
            };
            var q2 = from r in q
                     select new RangeInfo
                     {
                         RangeId = r.RangeId,
                         Total = r.Total,
                         Count = r.Count,
                         DonorCount = r.DonorCount,
                         PctCount = (decimal)r.Count / RangeTotal.Count * 100,
                         PctTotal = r.Total.Value / RangeTotal.Total.Value * 100,
                     };
            return q2;
        }
Пример #13
0
 public IEnumerable<AgeRangeInfo> TotalsByFundAgeRange(int fundid, DateTime dt1, DateTime dt2, string Pledges, int CampusId)
 {
     var list1 = (from r in DbUtil.Db.GetTotalContributionsAgeRange(dt1, dt2, CampusId, null, true)
                  select new AgeRangeInfo()
                  {
                      Range = r.Range,
                      Total = r.Total ?? 0,
                      Count = r.Count ?? 0,
                      DonorCount = r.DonorCount ?? 0,
                  }).ToList();
     RangeTotal = new RangeInfo
                      {
                          Count = list1.Sum(t => t.Count),
                          Total = list1.Sum(t => t.Total),
                          DonorCount = list1.Sum(t => t.DonorCount)
                      };
     var list = (from r in list1
                 select new AgeRangeInfo()
                 {
                     Range = r.Range,
                     Total = r.Total,
                     Count = r.Count,
                     DonorCount = r.DonorCount,
                     PctCount = (decimal)r.Count / RangeTotal.Count * 100,
                     PctTotal = r.Total / RangeTotal.Total * 100
                 }).ToList();
     return list;
     //            var q0 = from c in DbUtil.Db.Contributions
     //                     where dt1 <= c.ContributionDate.Value.Date
     //                     where c.ContributionDate.Value.Date <= dt2
     //                     where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId)
     //                     where c.FundId == fundid || fundid == 0
     //                     where CampusId == 0 || c.Person.CampusId == CampusId
     //                     select c;
     //            switch (Pledges)
     //            {
     //                case "true":
     //                    q0 = from c in q0
     //                         where c.ContributionTypeId == ContributionTypeCode.Pledge
     //                         select c;
     //                    break;
     //                case "false":
     //                    q0 = from c in q0
     //                         where c.ContributionStatusId == ContributionStatusCode.Recorded
     //                         where c.ContributionTypeId != ContributionTypeCode.Pledge
     ////                         where c.PostingDate != null
     //                         select c;
     //                    break;
     //                case "both":
     //                    q0 = from c in q0
     //                         where (c.ContributionTypeId != ContributionTypeCode.Pledge && c.ContributionStatusId == ContributionStatusCode.Recorded)
     //                                || c.ContributionTypeId == ContributionTypeCode.Pledge
     //                         where (c.ContributionTypeId != ContributionTypeCode.Pledge && c.PostingDate != null)
     //                                || c.ContributionTypeId == ContributionTypeCode.Pledge
     //                         select c;
     //                    break;
     //            }
     //
     //            var q = from c in q0
     //                    let age = c.Person.Age ?? 0
     //                    let agerange = age == 0 ? 0 : (age / 10) + 1
     //                    group c by agerange into g
     //                    orderby g.Key
     //                    select new AgeRangeInfo
     //                    {
     //                        RangeId = g.Key,
     //                        Total = g.Sum(t => t.ContributionAmount),
     //                        Count = g.Count(),
     //                        DonorCount = (from d in g
     //                                      group d by d.PeopleId into gd
     //                                      select gd).Count()
     //                    };
     //            var q2 = from r in q
     //                     select new AgeRangeInfo
     //                     {
     //                         RangeId = r.RangeId,
     //                         Total = r.Total,
     //                         Count = r.Count,
     //                         DonorCount = r.DonorCount,
     //                         PctCount = (decimal)r.Count / RangeTotal.Count * 100,
     //                         PctTotal = r.Total.Value / RangeTotal.Total.Value * 100,
     //                     };
     //            return q2;
 }
Пример #14
0
        public IEnumerable <AgeRangeInfo> TotalsByFundAgeRange(int fundid, DateTime dt1, DateTime dt2, string Pledges, int CampusId)
        {
            var q0 = from c in DbUtil.Db.Contributions
                     where dt1 <= c.ContributionDate.Value.Date
                     where c.ContributionDate.Value.Date <= dt2
                     where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId)
                     where c.FundId == fundid || fundid == 0
                     where CampusId == 0 || c.Person.CampusId == CampusId
                     select c;

            switch (Pledges)
            {
            case "true":
                q0 = from c in q0
                     where c.ContributionTypeId == ContributionTypeCode.Pledge
                     select c;
                break;

            case "false":
                q0 = from c in q0
                     where c.ContributionStatusId == ContributionStatusCode.Recorded
                     where c.ContributionTypeId != ContributionTypeCode.Pledge
                     where c.PostingDate != null
                     select c;
                break;

            case "both":
                q0 = from c in q0
                     where (c.ContributionTypeId != ContributionTypeCode.Pledge && c.ContributionStatusId == ContributionStatusCode.Recorded) ||
                     c.ContributionTypeId == ContributionTypeCode.Pledge
                     where (c.ContributionTypeId != ContributionTypeCode.Pledge && c.PostingDate != null) ||
                     c.ContributionTypeId == ContributionTypeCode.Pledge
                     select c;
                break;
            }

            var q = from c in q0
                    let age = c.Person.Age ?? 0
                              let agerange = age == 0 ? 0 : (age / 10) + 1
                                             group c by agerange into g
                                             orderby g.Key
                                             select new AgeRangeInfo
            {
                RangeId    = g.Key,
                Total      = g.Sum(t => t.ContributionAmount),
                Count      = g.Count(),
                DonorCount = (from d in g
                              group d by d.PeopleId into gd
                              select gd).Count()
            };

            RangeTotal = new RangeInfo
            {
                Count      = q.Sum(t => t.Count),
                Total      = q.Sum(t => t.Total),
                DonorCount = (from c in q0 group c by c.PeopleId into g select g).Count()
            };
            var q2 = from r in q
                     select new AgeRangeInfo
            {
                RangeId    = r.RangeId,
                Total      = r.Total,
                Count      = r.Count,
                DonorCount = r.DonorCount,
                PctCount   = (decimal)r.Count / RangeTotal.Count * 100,
                PctTotal   = r.Total.Value / RangeTotal.Total.Value * 100,
            };

            return(q2);
        }