Beispiel #1
0
        public Sys_UserInRole Find(Int32 id)
        {
            String         stmtId = "Sys_UserInRole.Find";
            Sys_UserInRole result = SqlMapper.QueryForObject <Sys_UserInRole>(stmtId, id);

            return(result);
        }
Beispiel #2
0
        public bool RemoveUsersFromRoles(string applicationName, string[] usernames, string[] rolenames)
        {
            bool b = false;

            try {
                SqlMapper.BeginTransaction();
                foreach (string username in usernames)
                {
                    foreach (string rolename in rolenames)
                    {
                        Sys_UserInRole ur = new Sys_UserInRole();
                        ur.ApplicationName = applicationName;
                        ur.UserName        = username;
                        ur.RoleName        = rolename;
                        Delete(ur);
                    }
                }
                SqlMapper.CommitTransaction();
                b = true;
            }
            catch (Exception ex) {
                SqlMapper.RollBackTransaction();
                throw ex;
            }
            return(b);
        }
Beispiel #3
0
        public string[] FindUsersInRole(string applicationName, string roleName, string usernameToMatch)
        {
            String         stmtId = "Sys_UserInRole.FindUsersInRole";
            Sys_UserInRole ur     = new Sys_UserInRole();

            ur.ApplicationName = applicationName;
            ur.RoleName        = roleName;
            ur.UserName        = usernameToMatch;
            IList <Sys_UserInRole> list = SqlMapper.QueryForList <Sys_UserInRole>(stmtId, ur);

            if (list.Count > 0)
            {
                string[] result = new string[list.Count];
                int      i      = 0;
                foreach (Sys_UserInRole t in list)
                {
                    result[i] = t.UserName;
                    i++;
                }
                return(result);
            }
            else
            {
                return(new string[0]);
            }
        }
 public bool Delete(Sys_UserInRole ur)
 {
     String stmtId = "Sys_UserInRole.DeleteByName";
     if (SqlMapper.Update(stmtId, ur) > 0) {
         return true;
     }
     else return false;
 }
Beispiel #5
0
        public IList <Sys_UserInRole> GetUsersInRole(string applicationName, string roleName)
        {
            String         stmtId = "Sys_UserInRole.GetUsersInRole";
            Sys_UserInRole ur     = new Sys_UserInRole();

            ur.ApplicationName = applicationName;
            ur.RoleName        = roleName;
            IList <Sys_UserInRole> result = SqlMapper.QueryForList <Sys_UserInRole>(stmtId, ur);

            return(result);
        }
Beispiel #6
0
        public IList <Sys_UserInRole> GetRolesForUser(string applicationName, string userName)
        {
            String         stmtId = "Sys_UserInRole.GetRolesForUser";
            Sys_UserInRole ur     = new Sys_UserInRole();

            ur.ApplicationName = applicationName;
            ur.UserName        = userName;
            IList <Sys_UserInRole> result = SqlMapper.QueryForList <Sys_UserInRole>(stmtId, ur);

            return(result);
        }
Beispiel #7
0
        public bool Delete(Sys_UserInRole ur)
        {
            String stmtId = "Sys_UserInRole.DeleteByName";

            if (SqlMapper.Update(stmtId, ur) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #8
0
        public bool Update(Sys_UserInRole obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            String stmtId = "Sys_UserInRole.Update";

            if (SqlMapper.Update(stmtId, obj) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #9
0
        public bool IsUserInRole(string applicationName, string userName, string roleName)
        {
            String         stmtId = "Sys_UserInRole.IsUserInRole";
            Sys_UserInRole ur     = new Sys_UserInRole();

            ur.ApplicationName = applicationName;
            ur.RoleName        = roleName;
            ur.UserName        = userName;
            int result = SqlMapper.QueryForObject <int>(stmtId, ur);

            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public bool AddUsersToRoles(string applicationName, string[] usernames, string[] rolenames)
 {
     bool b = false;
     try {
         SqlMapper.BeginTransaction();
         foreach (string username in usernames) {
             foreach (string rolename in rolenames) {
                 Sys_UserInRole ur = new Sys_UserInRole();
                 ur.ApplicationName = applicationName;
                 ur.UserName = username;
                 ur.RoleName = rolename;
                 Insert(ur);
             }
         }
         SqlMapper.CommitTransaction();
         b = true;
     }
     catch (Exception ex) {
         SqlMapper.RollBackTransaction();
         throw ex;
     }
     return b;
 }
        public string[] FindUsersInRole(string applicationName, string roleName, string usernameToMatch)
        {
            String stmtId = "Sys_UserInRole.FindUsersInRole";
            Sys_UserInRole ur = new Sys_UserInRole();
            ur.ApplicationName = applicationName;
            ur.RoleName = roleName;
            ur.UserName = usernameToMatch;
            IList<Sys_UserInRole> list = SqlMapper.QueryForList<Sys_UserInRole>(stmtId, ur);

            if (list.Count > 0) {
                string[] result  = new string[list.Count];
                int i = 0;
                foreach (Sys_UserInRole t in list) {
                    result[i] = t.UserName;
                    i++;
                }
                return result;
            }
            else { return new string[0]; }
        }
 public bool Update(Sys_UserInRole obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     String stmtId = "Sys_UserInRole.Update";
     if (SqlMapper.Update(stmtId, obj) > 0) {
         return true;
     }
     else return false;
 }
 public bool IsUserInRole(string applicationName, string userName, string roleName)
 {
     String stmtId = "Sys_UserInRole.IsUserInRole";
     Sys_UserInRole ur = new Sys_UserInRole();
     ur.ApplicationName = applicationName;
     ur.RoleName = roleName;
     ur.UserName = userName;
     int result = SqlMapper.QueryForObject<int>(stmtId, ur);
     if (result > 0) {
         return true;
     }
     else return false;
 }
 public IList<Sys_UserInRole> GetUsersInRole(string applicationName, string roleName)
 {
     String stmtId = "Sys_UserInRole.GetUsersInRole";
     Sys_UserInRole ur = new Sys_UserInRole();
     ur.ApplicationName = applicationName;
     ur.RoleName = roleName;
     IList<Sys_UserInRole> result = SqlMapper.QueryForList<Sys_UserInRole>(stmtId, ur);
     return result;
 }
 public IList<Sys_UserInRole> GetRolesForUser(string applicationName, string userName)
 {
     String stmtId = "Sys_UserInRole.GetRolesForUser";
     Sys_UserInRole ur = new Sys_UserInRole();
     ur.ApplicationName = applicationName;
     ur.UserName = userName;
     IList<Sys_UserInRole> result = SqlMapper.QueryForList<Sys_UserInRole>(stmtId, ur);
     return result;
 }