示例#1
0
 public System.Threading.Tasks.Task <TRole> FindByNameAsync(string roleName)
 {
     BusinessLogicLayer.Entity.RoleSecurity.Role roleEntity = new BusinessLogicLayer.Entity.RoleSecurity.Role(roleName);
     if (roleEntity == null)
     {
         return(null);
     }
     return(Task.FromResult <TRole>(roleEntity as TRole));
 }
示例#2
0
        public System.Threading.Tasks.Task DeleteAsync(TRole role)
        {
            if (role == null)
            {
                throw new ArgumentNullException("user");
            }
            BusinessLogicLayer.Entity.RoleSecurity.Role roleEntity = new BusinessLogicLayer.Entity.RoleSecurity.Role(role.RoleId);
            roleEntity.Delete();

            return(Task.FromResult <Object>(null));
        }
示例#3
0
        public System.Threading.Tasks.Task CreateAsync(TRole role)
        {
            if (role == null)
            {
                throw new ArgumentNullException("role");
            }

            BusinessLogicLayer.Entity.RoleSecurity.Role roleEntity = new BusinessLogicLayer.Entity.RoleSecurity.Role();
            roleEntity.Name     = role.Name;
            roleEntity.IsActive = true;
            roleEntity.Save();

            return(Task.FromResult <object>(null));
        }
示例#4
0
        public Task AddToRoleAsync(TUser user, string roleName)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            if (string.IsNullOrEmpty(roleName))
            {
                throw new ArgumentException("Argument cannot be null or empty: roleName.");
            }
            BusinessLogicLayer.Entity.RoleSecurity.Role role = new BusinessLogicLayer.Entity.RoleSecurity.Role(roleName);

            if (role != null)
            {
                BusinessLogicLayer.Entity.RoleSecurity.PersonRole prole = new BusinessLogicLayer.Entity.RoleSecurity.PersonRole();
                prole.PersonId = user.BusinessEntityId;
                prole.RoleId   = role.RoleId;
                prole.Save();
            }

            return(Task.FromResult <object>(null));
        }
示例#5
0
        public Task RemoveFromRoleAsync(TUser user, string roleName)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            if (string.IsNullOrEmpty(roleName))
            {
                throw new ArgumentNullException("roleName");
            }
            BusinessLogicLayer.Entity.RoleSecurity.Role role = new BusinessLogicLayer.Entity.RoleSecurity.Role(roleName);
            if (role != null)
            {
                BusinessLogicLayer.Entity.RoleSecurity.PersonRole prole = new BusinessLogicLayer.Entity.RoleSecurity.PersonRole(role.RoleId, user.BusinessEntityId);
                if (prole != null)
                {
                    prole.Delete();
                }
            }


            return(Task.FromResult <Object>(null));
        }