Exemplo n.º 1
0
        public List <T> Query <T>(Dictionary <string, string> DS)
        {
            string table = typeof(T).Name;

            try { return(WillORM.GetDBSource(table, WillORM.QueryBuilder(null, table, DS, null)).Cast <T>().ToList()); }
            catch (Exception e) { return(new List <T>()); }
        }
Exemplo n.º 2
0
        public static List <QE_CLASS> GetClasses(Dictionary <string, string> Ds)
        {
            Ds.Add("TERM", TermService.GetCurrentTerm().ID.ToString());
            Ds.Add("ACTIVE", "1");

            try { return(WillORM.GetDBSource("QE_CLASS", WillORM.QueryBuilder(null, "QE_CLASS", Ds, new string[] { "FORM", "NAME" })).Cast <QE_CLASS>().ToList()); }
            catch { return(null); }
        }
Exemplo n.º 3
0
        public static List <QE_USER> getActiveUsers()
        {
            Dictionary <string, string> Ds = new Dictionary <string, string>()
            {
                { "ACTIVE", "1" }
            };

            try { return(WillORM.GetDBSource("QE_USER", WillORM.QueryBuilder(null, "QE_USER", Ds, null)).Cast <QE_USER>().ToList()); }
            catch { return(new List <QE_USER>()); }
        }
Exemplo n.º 4
0
        public static List <HOMEWORK_SUBMISSION_LIST> getSubmission(int work_id)
        {
            Dictionary <string, string> condistions = new Dictionary <string, string>()
            {
                { "HOMEWORK", work_id.ToString() }
            };

            try { return(WillORM.GetDBSource("HOMEWORK_SUBMISSION_LIST", WillORM.QueryBuilder(null, "HOMEWORK_SUBMISSION_LIST", condistions, null)).Cast <HOMEWORK_SUBMISSION_LIST>().ToList()); }
            catch { return(null); }
        }
Exemplo n.º 5
0
        public static USER_GROUP GetGroup(int id)
        {
            Dictionary <string, string> DS = new Dictionary <string, string>()
            {
                { "ID", id.ToString() }
            };

            try { return(WillORM.GetDBSource("USER_GROUP", WillORM.QueryBuilder(null, "v", DS, null)).Cast <USER_GROUP>().FirstOrDefault()); }
            catch { return(null); }
        }
Exemplo n.º 6
0
        public static HOMEWORK_TYPE getType(int type_id)
        {
            Dictionary <string, string> DS = new Dictionary <string, string>()
            {
                { "ID", type_id.ToString() }
            };

            try { return(WillORM.GetDBSource("HOMEWORK_TYPE", WillORM.QueryBuilder(null, "HOMEWORK_TYPE", DS, null)).Cast <HOMEWORK_TYPE>().FirstOrDefault()); }
            catch { return(null); }
        }
Exemplo n.º 7
0
        public static List <STUDENT_GROUP> GetGroups()
        {
            Dictionary <string, string> Ds = new Dictionary <string, string>()
            {
                { "ACTIVE", "1" }
            };

            try { return(WillORM.GetDBSource("STUDENT_GROUP", WillORM.QueryBuilder(null, "STUDENT_GROUP", Ds, null)).Cast <STUDENT_GROUP>().ToList()); }
            catch (Exception e) { return(null); }
        }
Exemplo n.º 8
0
        public static List <HOMEWORK_TYPE> GetTypes()
        {
            Dictionary <string, string> Ds = new Dictionary <string, string>()
            {
                { "ACTIVE", "1" }
            };

            try { return(WillORM.GetDBSource("HOMEWORK_TYPE", WillORM.QueryBuilder(null, "HOMEWORK_TYPE", Ds, null)).Cast <HOMEWORK_TYPE>().ToList()); }
            catch { return(null); }
        }
Exemplo n.º 9
0
        public static List <HOMEWORK> GetFilteredWorks(int term_id, int group_id, int type_id)
        {
            List <MutliQuery> groupPram = new List <MutliQuery>();

            if (term_id > 0)
            {
                groupPram.Add(new MutliQuery()
                {
                    field1 = "TERM", field2 = term_id.ToString(), function = null
                });
            }
            if (group_id > 0)
            {
                groupPram.Add(new MutliQuery()
                {
                    field1 = "ID", field2 = group_id.ToString(), function = null
                }); groupPram.Add(new MutliQuery()
                {
                    field1 = "active", field2 = "1", function = null
                });
            }

            string typeParm = type_id > 0? WillORM.QueryBuilder("ID", "HOMEWORK_TYPE", new List <MutliQuery>()
            {
                new MutliQuery()
                {
                    field1 = "ID", field2 = type_id.ToString(), function = null
                }
            }, null) : null;

            List <MutliQuery> workParm = new List <MutliQuery>();

            if (groupPram.Any())
            {
                workParm.Add(new MutliQuery()
                {
                    field1 = "STUDENT_GROUP", field2 = "(" + WillORM.QueryBuilder("ID", "STUDENT_GROUP", groupPram, null) + ")", function = "in"
                });
            }
            if (!string.IsNullOrEmpty(typeParm))
            {
                workParm.Add(new MutliQuery()
                {
                    field1 = "HOMEWORK_TYPE", field2 = "(" + typeParm + ")", function = "in"
                });
            }
            workParm.Add(new MutliQuery()
            {
                field1 = "ACTIVE", field2 = "1", function = null
            });

            try { return(WillORM.GetDBSource("HOMEWORK", WillORM.QueryBuilder(null, "HOMEWORK", workParm, null)).Cast <HOMEWORK>().ToList()); }
            catch { return(null); }
        }
Exemplo n.º 10
0
        public static HOMEWORK GetWork(int id)
        {
            Dictionary <string, string> DS = new Dictionary <string, string>()
            {
                { "ID", id.ToString() },
                { "ACTIVE", "1" }
            };

            try { return(WillORM.GetDBSource("HOMEWORK", WillORM.QueryBuilder(null, "HOMEWORK", DS, null)).Cast <HOMEWORK>().FirstOrDefault()); }
            catch { return(null); }
        }
Exemplo n.º 11
0
        public static List <STUDENT_GROUP_STUDENT_LIST> GetGroupStudentMap(int group_id)
        {
            Dictionary <string, string> Ds = new Dictionary <string, string>()
            {
                { "STUDENT_GROUP", group_id.ToString() },
                { "ACTIVE", "1" }
            };

            try { return(WillORM.GetDBSource("STUDENT_GROUP_STUDENT_LIST", WillORM.QueryBuilder(null, "STUDENT_GROUP_STUDENT_LIST", Ds, null)).Cast <STUDENT_GROUP_STUDENT_LIST>().ToList()); }
            catch (Exception e) { return(null); }
        }
Exemplo n.º 12
0
        public static List <STUDENT_GROUP> GetStudentGroupByTerm(int term_id)
        {
            Dictionary <string, string> Ds = new Dictionary <string, string>()
            {
                { "TERM", term_id.ToString() },
                { "ACTIVE", "1" }
            };

            try { return(WillORM.GetDBSource("STUDENT_GROUP", WillORM.QueryBuilder(null, "STUDENT_GROUP", Ds, null)).Cast <STUDENT_GROUP>().ToList()); }
            catch (Exception e) { return(null); }
        }
Exemplo n.º 13
0
        public static CLASS_STUDENT_LIST getClassStudentListByStudent(int student_id)
        {
            Dictionary <string, string> Ds = new Dictionary <string, string>()
            {
                { "STUDENT", student_id.ToString() },
                { "ACTIVE", "1" }
            };

            try { return(WillORM.GetDBSource("CLASS_STUDENT_LIST", WillORM.QueryBuilder(null, "CLASS_STUDENT_LIST", Ds, null)).Cast <CLASS_STUDENT_LIST>().FirstOrDefault()); }
            catch { return(null); }
        }
Exemplo n.º 14
0
        public static List <QE_CLASS> GetClassesByTerm(int term)
        {
            Dictionary <string, string> Ds = new Dictionary <string, string>()
            {
                { "TERM", term.ToString() },
                { "ACTIVE", "1" }
            };

            try { return(WillORM.GetDBSource("QE_CLASS", WillORM.QueryBuilder(null, "QE_CLASS", Ds, new string[] { "FORM", "NAME" })).Cast <QE_CLASS>().ToList()); }
            catch { return(null); }
        }
Exemplo n.º 15
0
        public static QE_CLASS GetClass(int class_id)
        {
            Dictionary <string, string> Ds = new Dictionary <string, string>()
            {
                { "ID", class_id.ToString() },
                { "ACTIVE", "1" }
            };

            try { return(WillORM.GetDBSource("QE_CLASS", WillORM.QueryBuilder(null, "QE_CLASS", Ds, new string[] { "FORM", "NAME" })).Cast <QE_CLASS>().ToList().FirstOrDefault()); }
            catch { return(null); }
        }
Exemplo n.º 16
0
        public static TERM GetCurrentTerm()
        {
            List <MutliQuery> MQ = new List <MutliQuery>()
            {
                { new MutliQuery("ACTIVE", "=", "1") },
                { new MutliQuery("TERM_START", "<=", "CURRENT_TIMESTAMP") },
                { new MutliQuery("TERM_END", ">=", "CURRENT_TIMESTAMP") }
            };

            try { return(WillORM.GetDBSource("TERM", WillORM.QueryBuilder(null, "TERM", MQ, null)).Cast <TERM>().First()); }
            catch (Exception e) { return(new TERM()); }
        }
Exemplo n.º 17
0
        public static List <STUDENT> GetStudents(int term_id, int class_id)
        {
            string first = WillORM.QueryBuilder(null, "QE_CLASS", new List <MutliQuery>()
            {
                new MutliQuery()
                {
                    field1 = "ID", field2 = class_id.ToString(), function = null
                }, new MutliQuery()
                {
                    field1 = "TERM", field2 = term_id.ToString(), function = null
                }, new MutliQuery()
                {
                    field1 = "active", field2 = "1", function = null
                }
            }, null);
            string second = WillORM.QueryBuilder("STUDENT", "CLASS_STUDENT_LIST", new List <MutliQuery>()
            {
                new MutliQuery()
                {
                    field1 = "QE_CLASS", field2 = "(" + first + ")", function = "in"
                }, new MutliQuery()
                {
                    field1 = "active", field2 = "1", function = null
                }
            }, null);
            string third = WillORM.QueryBuilder(null, "STUDENT", new List <MutliQuery>()
            {
                new MutliQuery()
                {
                    field1 = "ID", field2 = "(" + second + ")", function = "in"
                }, new MutliQuery()
                {
                    field1 = "active", field2 = "1", function = null
                }
            }, null);

            try { return(WillORM.GetDBSource("STUDENT", third).Cast <STUDENT>().ToList()); }
            catch { return(new List <STUDENT>()); }
        }
Exemplo n.º 18
0
        public static List <STUDENT> GetActiveStudentsByClass(int qe_class)
        {
            string first = WillORM.QueryBuilder("STUDENT", "CLASS_STUDENT_LIST", new List <MutliQuery>()
            {
                new MutliQuery()
                {
                    field1 = "QE_CLASS", field2 = qe_class.ToString(), function = null
                }
            }, null);
            string second = WillORM.QueryBuilder(null, "STUDENT", new List <MutliQuery>()
            {
                new MutliQuery()
                {
                    field1 = "ID", field2 = "(" + first + ")", function = "in"
                }, new MutliQuery()
                {
                    field1 = "active", field2 = "1", function = null
                }
            }, null);

            try { return(WillORM.GetDBSource("STUDENT", second).Cast <STUDENT>().ToList()); }
            catch { return(new List <STUDENT>()); }
        }