public TenantStatusReport CurrentStatus()
        {
            var report = new TenantStatusReport();

            var parameters = new List<SqlParameter>();

            parameters.Add(new SqlParameter("TenId", TenantId));
            if (DistrictId > 0)
            {
                parameters.Add(new SqlParameter("DistrictId", DistrictId));
            }
            else if (BranchId > 0)
            {
                parameters.Add(new SqlParameter("BranchId", BranchId));
            }

            if (ProgramId > 0)
            {
                parameters.Add(new SqlParameter("ProgramId", ProgramId));
            }

            var result = SqlHelper.ExecuteReader(conn,
                                                 System.Data.CommandType.StoredProcedure,
                                                 "rpt_TenantStatusReport",
                                                 parameters.ToArray());

            if (result.Read())
            {
                report.RegisteredPatrons = result["RegisteredPatrons"] as int? ?? 0;
                report.PointsEarned = result["PointsEarned"] as int? ?? 0;
                report.PointsEarnedReading = result["PointsEarnedReading"] as int? ?? 0;
                report.ChallengesCompleted = result["ChallengesCompleted"] as int? ?? 0;
                report.SecretCodesRedeemed = result["SecretCodesRedeemed"] as int? ?? 0;
                report.AdventuresCompleted = result["AdventuresCompleted"] as int? ?? 0;
                report.BadgesAwarded = result["BadgesAwarded"] as int? ?? 0;
                report.RedeemedProgramCodes = result["RedeemedProgramCodes"] as int? ?? 0;

            }
            else {
                throw new Exception("No data returned.");
            }

            return report;
        }
Example #2
0
        public TenantStatusReport CurrentStatus()
        {
            var report = new TenantStatusReport();

            var parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("TenId", TenantId));
            if (DistrictId > 0)
            {
                parameters.Add(new SqlParameter("DistrictId", DistrictId));
            }
            else if (BranchId > 0)
            {
                parameters.Add(new SqlParameter("BranchId", BranchId));
            }

            if (ProgramId > 0)
            {
                parameters.Add(new SqlParameter("ProgramId", ProgramId));
            }

            var result = SqlHelper.ExecuteReader(conn,
                                                 System.Data.CommandType.StoredProcedure,
                                                 "rpt_TenantStatusReport",
                                                 parameters.ToArray());

            if (result.Read())
            {
                report.RegisteredPatrons    = result["RegisteredPatrons"] as int? ?? 0;
                report.PointsEarned         = result["PointsEarned"] as int? ?? 0;
                report.PointsEarnedReading  = result["PointsEarnedReading"] as int? ?? 0;
                report.ChallengesCompleted  = result["ChallengesCompleted"] as int? ?? 0;
                report.SecretCodesRedeemed  = result["SecretCodesRedeemed"] as int? ?? 0;
                report.AdventuresCompleted  = result["AdventuresCompleted"] as int? ?? 0;
                report.BadgesAwarded        = result["BadgesAwarded"] as int? ?? 0;
                report.RedeemedProgramCodes = result["RedeemedProgramCodes"] as int? ?? 0;
            }
            else
            {
                throw new Exception("No data returned.");
            }

            return(report);
        }