Exemplo n.º 1
0
        public BranchesStudents GetBranchesOfStudent(int studentId)
        {
            IList <DbParameter> parameters = new List <DbParameter>()
            {
                new MySqlParameter("@id", studentId)
            };

            string sql = $"SELECT {Tables.BranchStudents.allColumnsAlias} FROM {Tables.BranchStudents.TableName} WHERE {Tables.BranchStudents.StudentId.Name}=@id";

            DataTable table = _dbContext.GetDataTable(sql, parameters);

            if (table != null)
            {
                return(BranchStudentConverter.TableToBranchStudent(table));
            }
            return(new BranchesStudents());
        }
Exemplo n.º 2
0
        public BranchesStudents GetAllStudentsToBranch(int branchId)
        {
            IList <DbParameter> parameters = new List <DbParameter>()
            {
                new MySqlParameter("@branch_id", branchId),
                new MySqlParameter("@is_active", true),
                new MySqlParameter("@status", StatusInBranch.Approved.ToString())
            };
            string sql = $"SELECT {Tables.BranchStudents.allColumnsAlias} FROM {Tables.BranchStudents.TableName} WHERE {Tables.BranchStudents.BranchId.Name}=@branch_id" +
                         $" AND {Tables.BranchStudents.IsActive.Name}=@is_active AND {Tables.BranchStudents.Status.Name}=@status";
            DataTable table = _dbContext.GetDataTable(sql, parameters);

            if (table != null)
            {
                return(BranchStudentConverter.TableToBranchStudent(table));
            }
            return(new BranchesStudents());
        }
Exemplo n.º 3
0
        public BranchesStudents GetActiveBranchesOfStudent(int studentId, Student.Includes includes = Student.Includes.None)
        {
            IList <DbParameter> parameters = new List <DbParameter>()
            {
                new MySqlParameter("@is_active", true),
                new MySqlParameter("@student_id", studentId)
            };

            string sql = GetQueryForMultipleTables(includes) + $" WHERE {Tables.BranchStudents.TableName}.{Tables.BranchStudents.IsActive.Name}=@is_active AND {Tables.BranchStudents.StudentId.Name}=@student_id ";

            DataTable table = _dbContext.GetDataTable(sql, parameters);

            if (table != null)
            {
                return(BranchStudentConverter.TableToBranchStudent(table, includes));
            }
            return(new BranchesStudents());
        }
Exemplo n.º 4
0
        public BranchesStudents GetBranchesOfPendingStudents()
        {
            IList <DbParameter> parameters = new List <DbParameter>()
            {
                new MySqlParameter("@status", StatusInBranch.Pending.ToString()),
                new MySqlParameter("@is_active", false),
            };

            string sql = $"SELECT * FROM {Tables.BranchStudents.TableName} WHERE {Tables.BranchStudents.Status.Name}=@status" +
                         $" AND {Tables.BranchStudents.IsActive.Name}=@is_active";

            DataTable table = _dbContext.GetDataTable(Tables.BranchStudents.SelectAllTable, null);

            if (table != null)
            {
                return(BranchStudentConverter.TableToBranchStudent(table));
            }
            return(new BranchesStudents());
        }