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)); }
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)); }
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)); }
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)); }
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)); }