Ejemplo n.º 1
0
        public IEnumerable <DepositDateTotal> FetchData()
        {
            var authorizedFunds    = DbUtil.Db.ContributionFunds.ScopedByRoleMembership(DbUtil.Db).Select(f => f.FundId).ToList();
            var authorizedFundsCsv = string.Join(",", authorizedFunds);

            var connection = new SqlConnection(Util.ConnectionString);
            var parameters = new DynamicParameters();

            parameters.Add("authorizedFunds", authorizedFundsCsv);
            parameters.Add("startDate", Dt1 ?? DateTime.MinValue);
            parameters.Add("endDate", Dt2 ?? DateTime.MaxValue);

            var reader = connection.ExecuteReader("dbo.GetDepositDateTotalsUsingAuthorizedFunds", parameters, commandTimeout: 1200, commandType: CommandType.StoredProcedure);
            var items  = new List <DepositDateTotal>();

            while (reader.Read())
            {
                items.Add(new DepositDateTotal
                {
                    DepositDate        = reader["DepositDate"].ToNullableDate(),
                    Count              = reader["Count"].ToNullableInt(),
                    TotalContributions = reader["TotalContributions"].ToNullableDecimal(),
                    TotalHeader        = reader["TotalHeader"].ToNullableDecimal()
                });
            }

            Total = new DepositDateTotal
            {
                TotalHeader        = items.Sum(x => x.TotalHeader ?? 0.00m),
                TotalContributions = items.Sum(x => x.TotalContributions ?? 0.00m),
                Count = items.Sum(x => x.Count ?? 0)
            };

            return(items.OrderBy(x => x.DepositDate));
        }
Ejemplo n.º 2
0
        public IEnumerable <DepositDateTotal> FetchData()
        {
            var list = (from r in DbUtil.Db.ViewDepositDateTotals
                        where Dt1 == null || r.DepositDate >= Dt1
                        where Dt2 == null || r.DepositDate <= Dt2
                        orderby r.DepositDate
                        select r).ToList();

            Total = new DepositDateTotal()
            {
                TotalHeader        = list.Sum(vv => vv.TotalHeader),
                TotalContributions = list.Sum(vv => vv.TotalContributions),
                Count = list.Sum(vv => vv.Count ?? 0),
            };
            return(list);
        }