public string Execute(string instanceName, ApiMode apiMode, int localEducationAgencyId)
 {
     using (var sqlConnection = _databaseConnectionProvider.CreateNewConnection(instanceName, apiMode))
     {
         return(sqlConnection.Query <string>(Query, new { LEAid = localEducationAgencyId }).Single());
     }
 }
 public IReadOnlyList <SchoolYearType> Execute(string instanceName, ApiMode apiMode)
 {
     using (var connection = _databaseConnectionProvider.CreateNewConnection(instanceName, apiMode))
     {
         return(connection.Query <SchoolYearType>(
                    @"SELECT SchoolYear, SchoolYearDescription, CurrentSchoolYear
               FROM edfi.SchoolYearType
               ORDER BY SchoolYear").ToList());
     }
 }
        public StudentRaceReport Execute(string instanceName, ApiMode apiMode, int localEducationAgencyId)
        {
            using (var sqlConnection = _connectionProvider.CreateNewConnection(instanceName, apiMode))
            {
                var studentDemographicData = sqlConnection.Query <StudentDemographicData>(Query, new { LEAid = localEducationAgencyId }).ToList();

                var localEducationAgencyName = new GetLocalEducationAgencyByIdQuery(_connectionProvider).Execute(instanceName, apiMode, localEducationAgencyId);

                return(new StudentRaceReport(studentDemographicData, localEducationAgencyName, localEducationAgencyId));
            }
        }
Пример #4
0
 public bool IsValidDatabase(int odsInstanceNumericSuffix, ApiMode mode)
 {
     try
     {
         using (var odsInstanceConnection = _connectionProvider.CreateNewConnection(odsInstanceNumericSuffix, mode))
         {
             odsInstanceConnection.Open();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
        public TotalEnrollmentReport Execute(string instanceName, ApiMode apiMode, int localEducationAgencyId)
        {
            using (var sqlConnection = _databaseConnectionProvider.CreateNewConnection(instanceName, apiMode))
            {
                var enrollmentCount = sqlConnection.QueryFirstOrDefault <int>(EnrollmentsCountQuery, new { LEAId = localEducationAgencyId });

                var localEducationAgencyName = new GetLocalEducationAgencyByIdQuery(_databaseConnectionProvider).Execute(instanceName, apiMode, localEducationAgencyId);

                return(new TotalEnrollmentReport
                {
                    EnrollmentCount = enrollmentCount,
                    LocalEducationAgencyName = localEducationAgencyName,
                    LocalEducationAgencyId = localEducationAgencyId
                });
            }
        }
Пример #6
0
        public SchoolTypeReport Execute(string instanceName, ApiMode apiMode, int localEducationAgencyId)
        {
            using (var sqlConnection = _databaseConnectionProvider.CreateNewConnection(instanceName, apiMode))
            {
                var schoolCounts = sqlConnection.Query <SchoolCount>(SchoolsCountQuery, new { LEAId = localEducationAgencyId }).ToList();

                var localEducationAgencyName = new GetLocalEducationAgencyByIdQuery(_databaseConnectionProvider).Execute(instanceName, apiMode, localEducationAgencyId);

                return(new SchoolTypeReport
                {
                    SchoolCounts = schoolCounts,
                    LocalEducationAgencyName = localEducationAgencyName,
                    LocalEducationAgencyId = localEducationAgencyId
                });
            }
        }
Пример #7
0
        public SchoolYearType Execute(string instanceName, ApiMode apiMode)
        {
            using (var connection = _databaseConnectionProvider.CreateNewConnection(instanceName, apiMode))
            {
                var current = connection.Query <SchoolYearType>(
                    @"SELECT SchoolYear, SchoolYearDescription, CurrentSchoolYear
                      FROM edfi.SchoolYearType
                      WHERE CurrentSchoolYear = @CurrentSchoolYear", new { CurrentSchoolYear = true }).ToList();

                if (current.Count != 1)
                {
                    return(null);
                }

                return(current.Single());
            }
        }
Пример #8
0
        public void Execute(string instanceName, ApiMode apiMode, short schoolYear)
        {
            using (var connection = _databaseConnectionProvider.CreateNewConnection(instanceName, apiMode))
            {
                // Take special care that any modifications to the SQL here fall
                // within the common subset of SQL Server and Postgres syntax.

                var rowsAffected = connection.Execute(
                    @"UPDATE edfi.SchoolYearType
                      SET CurrentSchoolYear = 'true'
                      WHERE SchoolYear = @schoolYear", new { schoolYear });

                if (rowsAffected == 0)
                {
                    throw new Exception($"School year {schoolYear} does not exist.");
                }

                connection.Execute(
                    @"UPDATE edfi.SchoolYearType
                      SET CurrentSchoolYear = 'false'
                      WHERE SchoolYear <> @schoolYear", new { schoolYear });
            }
        }
 private string InferInstanceDatabaseName(int?newInstanceNumericSuffix, ApiMode mode)
 {
     using (var connection = _databaseConnectionProvider.CreateNewConnection(newInstanceNumericSuffix.Value, mode))
         return(connection.Database);
 }
        public string DatabaseName(int odsInstanceNumericSuffix, ApiMode mode)
        {
            using var connection = _connectionProvider.CreateNewConnection(odsInstanceNumericSuffix, mode);

            return(connection.Database);
        }