public ContributionSearchModel(int? peopleId, int? year)
 {
     api = new APIContributionSearchModel(DbUtil.Db);
     Setup();
     SearchInfo.PeopleId = peopleId;
     SearchInfo.Year = year;
 }
        public IEnumerable<FundTotalInfo> TotalsByFund()
        {
            List<FundTotalInfo> q = null;

            var api = new APIContributionSearchModel(DbUtil.Db)
            {
                model =
                {
                    StartDate = Dt1,
                    EndDate = Dt2,
                    IncludeUnclosedBundles = IncUnclosedBundles,
                    TaxNonTax = TaxDedNonTax,
                    CampusId = CampusId,
                    Status = ContributionStatusCode.Recorded,
                    Online = Online
                }
            };

            if (IncludeBundleType)
                q = (from c in api.FetchContributions()
                     let BundleType = c.BundleDetails.First().BundleHeader.BundleHeaderType.Description
                     let BundleTypeId = c.BundleDetails.First().BundleHeader.BundleHeaderTypeId
                     group c by new { c.FundId, c.QBSyncID, BundleTypeId, BundleType } into g
                     orderby g.Key.FundId, g.Key.QBSyncID, g.Key.BundleTypeId
                     select new FundTotalInfo
                                {
                                    BundleType = g.Key.BundleType,
                                    BundleTypeId = g.Key.BundleTypeId,
                                    FundId = g.Key.FundId,
                                    QBSynced = g.Key.QBSyncID ?? 0,
                                    FundName = g.First().ContributionFund.FundName,
                                    GeneralLedgerId = g.First().ContributionFund.FundIncomeAccount,
                                    Total = g.Sum(t => t.ContributionAmount).Value,
                                    Count = g.Count(),
                                    model = this
                                }).ToList();
            else
                q = (from c in api.FetchContributions()
                     group c by new { c.FundId, c.QBSyncID } into g
                     orderby g.Key.FundId, g.Key.QBSyncID
                     select new FundTotalInfo
                                {
                                    FundId = g.Key.FundId,
                                    QBSynced = g.Key.QBSyncID ?? 0,
                                    FundName = g.First().ContributionFund.FundName,
                                    GeneralLedgerId = g.First().ContributionFund.FundIncomeAccount,
                                    Total = g.Sum(t => t.ContributionAmount).Value,
                                    Count = g.Count(),
                                    model = this
                                }).ToList();

            FundTotal = new FundTotalInfo
                            {
                                Count = q.Sum(t => t.Count),
                                Total = q.Sum(t => t.Total),
                                model = this
                            };
            return q;
        }
 public ContributionSearchModel(ContributionSearchInfo m)
 {
     api = new APIContributionSearchModel(DbUtil.Db, m);
     Setup();
 }
 public ContributionSearchModel()
 {
     api = new APIContributionSearchModel(DbUtil.Db);
     Setup();
 }
 public ContributionSearchModel(APIContributionSearchModel api)
 {
     this.api = api;
     Setup();
 }
Exemple #6
0
        public List <LineChartDTO> GetAttendanceChartData(int[] orgIds)
        {
            var api = new CmsData.API.APIContributionSearchModel(DbUtil.Db);

            List <LineChartDTO> myFinalList = new List <LineChartDTO>();
            int            year             = DateTime.Now.Year;
            DateTime       firstDay         = new DateTime(year, 1, 1);
            DateTime       lastDay          = new DateTime(year, 12, 31);
            CMSDataContext db = DbUtil.Db;

            var myList = (from m in db.Meetings
                          where m.MeetingDate.Value.Year == (DateTime.Now.Year) &&
                          (from d in db.DivOrgs
                           join pd in db.ProgDivs on d.DivId equals pd.DivId
                           where d.OrgId == m.OrganizationId
                           select m.OrganizationId).Contains(m.OrganizationId)
                          group m by new { m.MeetingDate.Value.Month }
                          into grp
                          select new ChartDTO
            {
                Name = grp.First().MeetingDate.Value.ToString("MMM", CultureInfo.InvariantCulture),
                Count = Convert.ToInt32(grp.Sum(t => t.MaxCount).Value)
            });

            var myList1 = (from m in db.Meetings
                           where m.MeetingDate.Value.Year == (DateTime.Now.Year - 1) &&
                           (from d in db.DivOrgs
                            join pd in db.ProgDivs on d.DivId equals pd.DivId
                            where d.OrgId == m.OrganizationId
                            select m.OrganizationId).Contains(m.OrganizationId)
                           group m by new { m.MeetingDate.Value.Month }
                           into grp
                           select new ChartDTO
            {
                Name = grp.First().MeetingDate.Value.ToString("MMM", CultureInfo.InvariantCulture),
                Count = Convert.ToInt32(grp.Sum(t => t.MaxCount).Value)
            });

            if (orgIds.IsNotNull() && orgIds[0] > 0)
            {
                if (!(orgIds.Length == 1 && orgIds[0].Equals(0)))
                {
                    myList = (from m in db.Meetings
                              where m.MeetingDate.Value.Year == (DateTime.Now.Year) &&
                              orgIds.Contains(m.OrganizationId)
                              group m by new { m.MeetingDate.Value.Month }
                              into grp
                              select new ChartDTO
                    {
                        Name = grp.First().MeetingDate.Value.ToString("MMM", CultureInfo.InvariantCulture),
                        Count = Convert.ToInt32(grp.Sum(t => t.MaxCount).Value)
                    });

                    myList1 = (from m in db.Meetings
                               where m.MeetingDate.Value.Year == (DateTime.Now.Year - 1) &&
                               orgIds.Contains(m.OrganizationId)
                               group m by new { m.MeetingDate.Value.Month }
                               into grp
                               select new ChartDTO
                    {
                        Name = grp.First().MeetingDate.Value.ToString("MMM", CultureInfo.InvariantCulture),
                        Count = Convert.ToInt32(grp.Sum(t => t.MaxCount).Value)
                    });
                }
            }

            var myList3 = DateTimeFormatInfo.InvariantInfo.AbbreviatedMonthNames;

            var emptytableQuery = (from m in myList3
                                   where m.HasValue()
                                   select new ChartDTO
            {
                Name = m,
                Count = 0
            });

            myFinalList = (from e in emptytableQuery
                           join t in myList on e.Name equals t.Name into tm
                           join s in myList1 on e.Name equals s.Name into sm
                           from rdj in tm.DefaultIfEmpty()
                           from sdj in sm.DefaultIfEmpty()
                           select new LineChartDTO()
            {
                ChartName = "MONTHLY ATTENDANCE ANALYSIS",
                CurYear = DateTime.Now.Year,
                PreYear = DateTime.Now.Year - 1,
                Name = e.Name,
                Count = rdj == null ? 0 : rdj.Count,
                Count2 = sdj == null ? 0 : sdj.Count
            }).ToList();

            return(myFinalList);
        }