コード例 #1
0
        /// <summary>
        /// Returns a list of teachers from a given school.
        /// </summary>
        /// <param name="schoolId">The id of the school. (Guid)</param>
        /// <returns>A list of teachers from a given school.</returns>
        public static List <Teacher> LoadAllTeachers(Guid schoolId)
        {
            Stopwatch watch = Stopwatch.StartNew();

            string sql = @"SELECT * FROM dbo.Teachers
                WHERE SchoolId = @Id";

            List <Teacher> output = AzureDataStore.LoadDataWithGuid <Teacher>(sql, schoolId);

            watch.Stop();
            Analytics.TrackEvent(nameof(LoadAllTeachers), new Dictionary <string, string>
            {
                { "ElapsedTime", $"{ watch.ElapsedMilliseconds } ms" }
            });

            return(output);
        }
コード例 #2
0
        /// <summary>
        /// Returns a list of periods that a class has.
        /// </summary>
        /// <param name="classId">The Id of the class. (Guid)</param>
        /// <returns>List of periods that a class has.</returns>
        public static List <int> LoadPeriods(Guid classId)
        {
            Stopwatch watch = Stopwatch.StartNew();

            string sql = @"SELECT (Period) FROM dbo.Class_Periods
                WHERE ClassId = (@Id)";

            List <int> output = AzureDataStore.LoadDataWithGuid <int>(sql, classId);

            watch.Stop();
            Analytics.TrackEvent(nameof(LoadPeriods), new Dictionary <string, string>
            {
                { "ElapsedTime", $"{ watch.ElapsedMilliseconds } ms" }
            });

            return(output);
        }
コード例 #3
0
        /// <summary>
        /// Returns a User object, given it's Id.
        /// </summary>
        /// <param name="userId">The id of the user. (Guid)</param>
        /// <returns>The user.</returns>
        public static User LoadUserFromId(Guid userId)
        {
            Stopwatch watch = Stopwatch.StartNew();

            string sql = @"SELECT * FROM dbo.Users
                WHERE Id = @Id";

            User output = AzureDataStore.LoadDataWithGuid <User>(sql, userId)
                          .FirstOrDefault();

            watch.Stop();
            Analytics.TrackEvent(nameof(LoadUserFromId), new Dictionary <string, string>
            {
                { "ElapsedTime", $"{ watch.ElapsedMilliseconds } ms" }
            });

            return(output);
        }
コード例 #4
0
        /// <summary>
        /// Returns the name of a school, given it's Id.
        /// </summary>
        /// <param name="schoolId">The Id of the school. (Guid)</param>
        /// <returns>The name of the school. (string)</returns>
        public static string GetSchoolName(Guid schoolId)
        {
            Stopwatch watch = Stopwatch.StartNew();

            string sql = @"SELECT Name FROM dbo.Schools
                WHERE Id = @Id";

            string output = AzureDataStore.LoadDataWithGuid <string>(sql, schoolId)
                            .FirstOrDefault();

            watch.Stop();
            Analytics.TrackEvent(nameof(GetSchoolName), new Dictionary <string, string>
            {
                { "ElapsedTime", $"{ watch.ElapsedMilliseconds } ms" }
            });

            return(output);
        }
コード例 #5
0
        /// <summary>
        /// Returns a list of classes that a user is enrolled in, given the
        /// user's Id.
        /// </summary>
        /// <param name="userId">The user's Id (Guid)</param>
        /// <returns>List of classes that the user is enrolled in.</returns>
        public static List <Class> LoadEnrolledClasses(Guid userId)
        {
            Stopwatch watch = Stopwatch.StartNew();

            string sql = @"
                SELECT dbo.Classes.Id, dbo.Class_Users.Period, dbo.Classes.Name, dbo.Classes.TeacherId
                FROM dbo.Classes
                JOIN dbo.Class_Users
                ON dbo.Classes.Id = dbo.Class_Users.ClassId 
                WHERE dbo.Class_Users.UserId = @Id";

            List <Class> output = AzureDataStore.LoadDataWithGuid <Class>(sql, userId);

            watch.Stop();
            Analytics.TrackEvent(nameof(LoadEnrolledClasses), new Dictionary <string, string>
            {
                { "ElapsedTime", $"{ watch.ElapsedMilliseconds } ms" }
            });

            return(output);
        }