Ejemplo n.º 1
0
 public static SoftFluent.Samples.Thinktecture.IdentityServer.UserCollection PageLoadUsersRolesByRole(int pageIndex, int pageSize, System.Guid roleId)
 {
     SoftFluent.Samples.Thinktecture.IdentityServer.Role role = SoftFluent.Samples.Thinktecture.IdentityServer.Role.Load(roleId);
     if ((role == null))
     {
         return(new SoftFluent.Samples.Thinktecture.IdentityServer.UserCollection());
     }
     return(SoftFluent.Samples.Thinktecture.IdentityServer.UserCollection.PageLoadUsersRolesByRole(pageIndex, pageSize, null, role));
 }
Ejemplo n.º 2
0
        public System.Threading.Tasks.Task <bool> IsInRoleAsync(SoftFluent.Samples.Thinktecture.IdentityServer.User user, string roleName)
        {
            SoftFluent.Samples.Thinktecture.IdentityServer.Role role = SoftFluent.Samples.Thinktecture.IdentityServer.Role.LoadByName(roleName);
            if (role == null)
            {
                throw new System.ArgumentException(string.Format("role '{0}' not found", roleName), "roleName");
            }

            return(System.Threading.Tasks.Task.FromResult(user.Roles.Contains(role)));
        }
Ejemplo n.º 3
0
        private void LoadUsersRolesByRole(int pageIndex, int pageSize, CodeFluent.Runtime.PageOptions pageOptions, System.Data.IDataReader reader, SoftFluent.Samples.Thinktecture.IdentityServer.Role role)
        {
            if ((reader == null))
            {
                throw new System.ArgumentNullException("reader");
            }
            if ((pageIndex < 0))
            {
                pageIndex = 0;
            }
            if ((pageSize < 0))
            {
                if ((pageOptions != null))
                {
                    pageSize = pageOptions.DefaultPageSize;
                }
                else
                {
                    pageSize = int.MaxValue;
                }
            }
            CodeFluent.Runtime.CodeFluentEntityState roleState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
            if ((role != null))
            {
                roleState = role.EntityState;
            }
            this._usersRoleRoles = role;
            this.BaseList.Clear();
            this.BaseTable.Clear();
            int  count     = 0;
            int  readCount = 0;
            bool readerRead;

            for (readerRead = reader.Read(); ((readerRead == true) &&
                                              ((count < this.MaxCount) &&
                                               (count < pageSize))); readerRead = reader.Read())
            {
                readCount = (readCount + 1);
                if ((CodeFluent.Runtime.CodeFluentPersistence.CanAddEntity(pageIndex, pageSize, pageOptions, readCount) == true))
                {
                    SoftFluent.Samples.Thinktecture.IdentityServer.User user = new SoftFluent.Samples.Thinktecture.IdentityServer.User();
                    ((CodeFluent.Runtime.ICodeFluentEntity)(user)).ReadRecord(reader);
                    if ((this.BaseContains(user) == false))
                    {
                        this.BaseAdd(user);
                        count = (count + 1);
                    }
                    user.EntityState = CodeFluent.Runtime.CodeFluentEntityState.Unchanged;
                }
            }
            if ((role != null))
            {
                role.EntityState = roleState;
            }
        }
Ejemplo n.º 4
0
        public System.Threading.Tasks.Task AddToRoleAsync(SoftFluent.Samples.Thinktecture.IdentityServer.User user, string roleName)
        {
            SoftFluent.Samples.Thinktecture.IdentityServer.Role role = SoftFluent.Samples.Thinktecture.IdentityServer.Role.LoadByName(roleName);
            if (role == null)
            {
                throw new System.ArgumentException(string.Format("role '{0}' not found", roleName), "roleName");
            }

            role.Users.Add(user);
            role.Save();
            return(System.Threading.Tasks.Task.FromResult(0));
        }
Ejemplo n.º 5
0
 public static System.Data.IDataReader DataLoadUsersRolesByRole(SoftFluent.Samples.Thinktecture.IdentityServer.Role role)
 {
     System.Data.IDataReader reader = SoftFluent.Samples.Thinktecture.IdentityServer.UserCollection.PageDataLoadUsersRolesByRole(null, role);
     return(reader);
 }
Ejemplo n.º 6
0
 public static System.Data.IDataReader PageDataLoadUsersRolesByRole(CodeFluent.Runtime.PageOptions pageOptions, SoftFluent.Samples.Thinktecture.IdentityServer.Role role)
 {
     if ((role == null))
     {
         return(null);
     }
     if ((role.Id.Equals(CodeFluentPersistence.DefaultGuidValue) == true))
     {
         CodeFluent.Runtime.CodeFluentRuntimeException.Throw("invalidEntityKey", "Id", "role", "SoftFluent.Samples.Thinktecture.IdentityServer.Role");
     }
     CodeFluent.Runtime.CodeFluentPersistence persistence = CodeFluentContext.Get(SoftFluent.Samples.Thinktecture.IdentityServer.Constants.SoftFluent_Samples_Thinktecture_IdentityServerStoreName).Persistence;
     persistence.CreateStoredProcedureCommand(null, "User", "LoadUsersRolesByRole");
     persistence.AddParameter("@RoleId", role.Id, CodeFluentPersistence.DefaultGuidValue);
     if ((pageOptions != null))
     {
         System.Collections.IEnumerator enumerator = pageOptions.OrderByArguments.GetEnumerator();
         bool b;
         int  index = 0;
         for (b = enumerator.MoveNext(); b; b = enumerator.MoveNext())
         {
             CodeFluent.Runtime.OrderByArgument argument = ((CodeFluent.Runtime.OrderByArgument)(enumerator.Current));
             persistence.AddParameter(string.Format("@_orderBy{0}", index), argument.Name);
             persistence.AddParameter(string.Format("@_orderByDirection{0}", index), ((int)(argument.Direction)));
             index = (index + 1);
         }
     }
     System.Data.IDataReader reader = CodeFluentContext.Get(SoftFluent.Samples.Thinktecture.IdentityServer.Constants.SoftFluent_Samples_Thinktecture_IdentityServerStoreName).Persistence.ExecuteReader();
     return(reader);
 }
Ejemplo n.º 7
0
 public static SoftFluent.Samples.Thinktecture.IdentityServer.UserCollection LoadUsersRolesByRole(SoftFluent.Samples.Thinktecture.IdentityServer.Role role)
 {
     SoftFluent.Samples.Thinktecture.IdentityServer.UserCollection ret = SoftFluent.Samples.Thinktecture.IdentityServer.UserCollection.PageLoadUsersRolesByRole(int.MinValue, int.MaxValue, null, role);
     return(ret);
 }
Ejemplo n.º 8
0
 public static SoftFluent.Samples.Thinktecture.IdentityServer.UserCollection PageLoadUsersRolesByRole(int pageIndex, int pageSize, CodeFluent.Runtime.PageOptions pageOptions, SoftFluent.Samples.Thinktecture.IdentityServer.Role role)
 {
     if ((pageIndex < 0))
     {
         pageIndex = 0;
     }
     if ((pageSize < 0))
     {
         if ((pageOptions != null))
         {
             pageSize = pageOptions.DefaultPageSize;
         }
         else
         {
             pageSize = int.MaxValue;
         }
     }
     SoftFluent.Samples.Thinktecture.IdentityServer.UserCollection ret = new SoftFluent.Samples.Thinktecture.IdentityServer.UserCollection();
     System.Data.IDataReader reader = null;
     try
     {
         reader = SoftFluent.Samples.Thinktecture.IdentityServer.UserCollection.PageDataLoadUsersRolesByRole(pageOptions, role);
         if ((reader == null))
         {
             return(ret);
         }
         ret.LoadUsersRolesByRole(pageIndex, pageSize, pageOptions, reader, role);
     }
     finally
     {
         if ((reader != null))
         {
             reader.Dispose();
         }
         CodeFluent.Runtime.CodeFluentPersistence.CompleteCommand(SoftFluent.Samples.Thinktecture.IdentityServer.Constants.SoftFluent_Samples_Thinktecture_IdentityServerStoreName);
     }
     return(ret);
 }
Ejemplo n.º 9
0
 public UserCollection(SoftFluent.Samples.Thinktecture.IdentityServer.Role usersRoleRoles)
 {
     this._blm1728787363  = new CodeFluent.Runtime.Utilities.BindingListManager <SoftFluent.Samples.Thinktecture.IdentityServer.User>(this);
     this._usersRoleRoles = usersRoleRoles;
 }