Example #1
0
        public static Group GetGroupByID(int groupID)
        {
            Group group = null;
            ThingReader <Group> thingReader;
            Func <FieldInfo, IDataRecord, object> customApply = CustomApply;

            using (DataManager.Current.OpenConnection())
            {
                SqlCommand sqlCommand = DataManager.CreateCommand(@"SELECT GroupID,
																			Name,
																			IsActive,
																			AccountAdmin     
																			FROM User_GUI_UserGroup
																			WHERE GroupID=@GroupID:Int"                                                                            );
                sqlCommand.Parameters["@GroupID"].Value = groupID;

                thingReader = new ThingReader <Group>(sqlCommand.ExecuteReader(), CustomApply);
                if (thingReader.Read())
                {
                    group = (Group)thingReader.Current;
                }
            }
            if (group != null)
            {
                group = MapperUtility.ExpandObject <Group>(group, customApply);
            }

            return(group);
        }
        public static List <User> GetAllUsers()
        {
            List <User>        users = new List <User>();
            ThingReader <User> thingReader;
            Func <FieldInfo, IDataRecord, object> customApply = CustomApply;

            using (DataManager.Current.OpenConnection())
            {
                SqlCommand sqlCommand = DataManager.CreateCommand("SELECT UserID,Name,AccountAdmin,Email FROM User_GUI_User ORDER BY UserID");


                thingReader = new ThingReader <User>(sqlCommand.ExecuteReader(), CustomApply);
                while (thingReader.Read())
                {
                    users.Add((User)thingReader.Current);
                }
            }
            if (users != null && users.Count > 0)
            {
                for (int i = 0; i < users.Count; i++)
                {
                    users[i] = MapperUtility.ExpandObject <User>(users[i], customApply);
                }
            }
            return(users);
        }
Example #3
0
        public static List <Group> GetAllGroups()
        {
            List <Group>        groups = new List <Group>();
            ThingReader <Group> thingReader;
            Func <FieldInfo, IDataRecord, object> customApply = CustomApply;

            using (DataManager.Current.OpenConnection())
            {
                SqlCommand sqlCommand = DataManager.CreateCommand("SELECT GroupID,Name,AccountAdmin FROM User_GUI_UserGroup ORDER BY GroupID");


                thingReader = new ThingReader <Group>(sqlCommand.ExecuteReader(), CustomApply);
                while (thingReader.Read())
                {
                    groups.Add((Group)thingReader.Current);
                }
            }
            if (groups != null && groups.Count > 0)
            {
                for (int i = 0; i < groups.Count; i++)
                {
                    groups[i] = MapperUtility.ExpandObject <Group>(groups[i], customApply);
                }
            }
            return(groups);
        }
        public static User GetUserByID(int id)
        {
            User user = null;
            ThingReader <User> thingReader;
            Func <FieldInfo, IDataRecord, object> customApply = CustomApply;

            using (DataManager.Current.OpenConnection())
            {
                SqlCommand sqlCommand = DataManager.CreateCommand("User_GetByID(@userID:int)", CommandType.StoredProcedure);
                sqlCommand.Parameters["@userID"].Value = id;

                thingReader = new ThingReader <User>(sqlCommand.ExecuteReader(), CustomApply);
                if (thingReader.Read())
                {
                    user = (User)thingReader.Current;
                }
            }
            if (user != null)
            {
                user = MapperUtility.ExpandObject <User>(user, customApply);
            }

            return(user);
            //System.Data.SqlClient.SqlCommand cmd = Easynet.Edge.Core.Data.DataManager.CreateCommand("User_GetAllPermissions(@userID:int)");
        }