public bool RemoveFromRole(User user, string roleName) { IUserRoleRepository repo = _data_repository_factory.GetIdentityDataRepository <IUserRoleRepository>(); IIdentityRoleBusinessEngine role_be = _business_engine_factory.GetBusinessEngine <IIdentityRoleBusinessEngine>(); var role = role_be.FindByName(roleName); UserRoleData ur = new UserRoleData() { RoleID = role.RoleId, UserID = user.UserId }; repo.Delete(ur); return(true); }
public int AddToRole(User user, string roleName) { IUserRoleRepository repo = _data_repository_factory.GetIdentityDataRepository <IUserRoleRepository>(); IIdentityRoleBusinessEngine role_be = _business_engine_factory.GetBusinessEngine <IIdentityRoleBusinessEngine>(); var role = role_be.FindByName(roleName); Log.Debug($"Adding Role User Rel: Role:{role.RoleId}; UserID: {user.UserId}"); UserRoleData ur = new UserRoleData() { RoleID = role.RoleId, UserID = user.UserId }; return(repo.Save(ur)); }