Exemple #1
0
        private List <object> RunQuery(string data)
        {
            using (CHUMDB context = new CHUMDB())
            {
                DBGeneric <User> Users = new DBGeneric <User>(context);
                var test = Users.Read();

                List <object> returnvalue = null;

                User_Type UT = (from ut in context.User_Type
                                where ut.Label == data
                                select ut).FirstOrDefault();
                if (UT == null)
                {
                    throw new Exception("Can't Find User Type Paramater in DB: " + data);
                }

                if (UT.Label == "Teacher")
                {
                    returnvalue = (from usr in Users.Read()
                                   where usr.User_Type_ID == UT.ID &&
                                   usr.UserName != null &&
                                   !string.IsNullOrWhiteSpace(usr.UserName)
                                   orderby usr.User_Type_ID, usr.Year_Level
                                   select new
                    {
                        First_Name = usr.Preferred_First_Name,
                        Surname = usr.Preferred_Last_Name,
                        Email = usr.UserName + "@eq.edu.au"
                    }).ToList <object>();
                }

                if (data == "Student")
                {
                    returnvalue = (from usr in Users.Read()
                                   where usr.User_Type_ID == UT.ID &&
                                   usr.Exit_Date == null &&
                                   usr.UserName != null &&
                                   !string.IsNullOrWhiteSpace(usr.UserName)
                                   orderby usr.User_Type_ID, usr.Year_Level
                                   select new
                    {
                        First_Name = usr.Preferred_First_Name,
                        Surname = usr.Preferred_Last_Name,
                        Email = usr.UserName + "@eq.edu.au",
                        YearGroup = "Year " + usr.Year_Level
                    }).ToList <object>();
                }
                return(returnvalue ?? new List <object>());
            }
        }
Exemple #2
0
        public void LoadData()
        {
            using (CHUMDB context = new CHUMDB())
            {
                DBGeneric <User> Users = new DBGeneric <User>(context);

                List <object> returnvalue = null;
                string        paramavalue = this._Paramaters["User_Type"];

                User_Type UT = (from ut in context.User_Type
                                where ut.Label == paramavalue
                                select ut).FirstOrDefault();


                if (paramavalue == "Teacher")
                {
                    returnvalue = (from usr in Users.Read()
                                   where usr.User_Type_ID == UT.ID &&
                                   usr.Exit_Date == null &&
                                   usr.UserName != null
                                   select new
                    {
                        First_Name = usr.Preferred_First_Name,
                        Last_Name = usr.Preferred_Last_Name,
                        Email = usr.UserName + "@eq.edu.au"
                    }).ToList <object>();
                }

                if (paramavalue == "Student")
                {
                    returnvalue = (from usr in Users.Read()
                                   where usr.User_Type_ID == UT.ID &&
                                   usr.Exit_Date == null &&
                                   usr.UserName != null
                                   select new
                    {
                        First_Name = usr.Preferred_First_Name,
                        Last_Name = usr.Preferred_Last_Name,
                        Email = usr.UserName + "@eq.edu.au",
                        YearGroup = usr.Year_Level
                    }).ToList <object>();
                }

                this._Data = returnvalue ?? new List <object>();;
            }
        }
Exemple #3
0
        public void LoadData()
        {
            using (CHUMDB context = new CHUMDB())
            {
                DBGeneric <User> Users = new DBGeneric <User>(context);

                List <object> returnvalue     = null;
                string        DefaultPassword = this._Paramaters["Password"];
                string        Enabled         = this._Paramaters["Enabled"];

                returnvalue = (from usr in Users.Read()
                               where usr.Exit_Date == null &&
                               usr.UserName != null
                               select new
                {
                    username = usr.UserName,
                    password = (usr.User_Type_ID == 2 ? "Staff" : "Student"),
                    primary_email_password = usr.UserName + "@eq.edu.au",
                    given_name = usr.Preferred_First_Name,
                    surname = usr.Preferred_Last_Name,
                    gender = usr.Sex,
                    library_barcode = usr.Barcode,
                    admin_system_id = usr.Barcode,
                    graduation_yeat = "",
                    form_class = "",
                    enabled = "Y",
                    staff_member = (usr.User_Type_ID == 2 ? "true" : "false"),
                }).ToList <object>();



                //ew
                //{

                //}).ToList<object>();
                this._Data = returnvalue ?? new List <object>();;
            }
        }
Exemple #4
0
        private List <object> RunQuery(ExportParamater UserType, ExportParamater DefaultPassword)
        {
            List <object> returnvalue = new List <object>();

            using (CHUMDB context = new CHUMDB())
            {
                DBGeneric <User>      Users     = new DBGeneric <User>(context);
                DBGeneric <User_Type> UserTypes = new DBGeneric <User_Type>(context);

                User_Type UT = (from ut in UserTypes.Read()
                                where ut.Label.ToString() == UserType.Data.ToString()
                                select ut).FirstOrDefault();

                if (UT == null)
                {
                    throw new Exception("Can't Find User Type Paramater in DB: " + UserType.Data.ToString());
                }

                if (UT.Label == "Student")
                {
                    returnvalue = (from usr in Users.Read()
                                   where usr.Exit_Date == null &&
                                   usr.UserName != null &&
                                   !string.IsNullOrWhiteSpace(usr.UserName) &&
                                   usr.User_Type_ID == UT.ID
                                   orderby usr.User_Type_ID, usr.Year_Level
                                   select new
                    {
                        username = usr.UserName + "@eq.edu.au",
                        password = DefaultPassword.Data.ToString(),
                        primary_email = usr.UserName + "@eq.edu.au",
                        given_name = usr.Preferred_First_Name,
                        surname = usr.Preferred_Last_Name,
                        library_barcode = usr.ID,
                        admin_system_id = usr.ID,
                        enabled = "Y",
                        staff_member = (UT.Label == "Student" ? "N" : "Y"),
                        gender = usr.Sex,
                        form_class = usr.Form_Class ?? " ",
                        graduation_year = CalcGradYear(usr.Year_Level),
                    }).ToList <object>();
                }

                if (UT.Label == "Teacher")
                {
                    returnvalue = (from usr in Users.Read()
                                   where usr.Exit_Date == null &&
                                   usr.UserName != null &&
                                   !string.IsNullOrWhiteSpace(usr.UserName) &&
                                   usr.User_Type_ID == UT.ID
                                   orderby usr.User_Type_ID, usr.Year_Level
                                   select new
                    {
                        username = usr.UserName + "@eq.edu.au",
                        password = DefaultPassword.Data.ToString(),
                        primary_email = usr.UserName + "@eq.edu.au",
                        given_name = usr.Preferred_First_Name,
                        surname = usr.Preferred_Last_Name,
                        library_barcode = usr.Barcode,
                        admin_system_id = usr.Barcode,
                        enabled = "Y",
                        staff_member = (UT.Label == "Student" ? "N" : "Y"),
                    }).ToList <object>();
                }
            }

            return(returnvalue);
        }