Beispiel #1
0
        public async Task<ISiteRole> FetchRole(int siteId, string roleName)
        {
            SiteRole role = null;

            using (DbDataReader reader = await dbRoles.GetByName(siteId, roleName))
            {
                if (reader.Read())
                {
                    role = new SiteRole();
                    role.LoadFromReader(reader);
                }
            }

            return role;

        }
Beispiel #2
0
        public async Task<IList<ISiteRole>> GetRolesBySite(
            int siteId,
            string searchInput,
            int pageNumber,
            int pageSize)
        {
            IList<ISiteRole> roles = new List<ISiteRole>();
            using (DbDataReader reader = await dbRoles.GetPage(siteId, searchInput, pageNumber, pageSize))
            {
                while (reader.Read())
                {
                    SiteRole role = new SiteRole();
                    role.LoadFromReader(reader);
                    role.MemberCount = Convert.ToInt32(reader["MemberCount"]);

                    roles.Add(role);
                }
            }

            return roles;

        }
Beispiel #3
0
        public async Task<IList<ISiteRole>> GetRolesBySite(
            int siteId,
            string searchInput,
            int pageNumber,
            int pageSize,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            IList<ISiteRole> roles = new List<ISiteRole>();
            using (DbDataReader reader = await dbRoles.GetPage(
                siteId, 
                searchInput, 
                pageNumber, 
                pageSize,
                cancellationToken))
            {
                while (reader.Read())
                {
                    SiteRole role = new SiteRole();
                    role.LoadFromReader(reader);
                    role.MemberCount = Convert.ToInt32(reader["MemberCount"]);

                    roles.Add(role);
                }
            }

            return roles;

        }
Beispiel #4
0
        //public int GetRoleMemberCount(int roleId)
        //{
        //    // TODO: implement actual select count from db
        //    // this is works but is not ideal
        //    int count = 0;
        //    using (DbDataReader reader = dbRoles.GetRoleMembers(roleId))
        //    {
        //        while (reader.Read())
        //        {
        //            count += 1;
        //        }
        //    }

        //    return count;

        //}

        public async Task<ISiteRole> FetchRole(int roleId)
        {
            using (DbDataReader reader = await dbRoles.GetById(roleId))
            {
                if (reader.Read())
                {
                    SiteRole role = new SiteRole();
                    role.LoadFromReader(reader);
                    return role;
                }
            }

            return null;
        }
Beispiel #5
0
        public async Task<ISiteRole> FetchRole(
            int siteId, 
            string roleName, 
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            SiteRole role = null;

            using (DbDataReader reader = await dbRoles.GetByName(
                siteId, 
                roleName,
                cancellationToken))
            {
                if (reader.Read())
                {
                    role = new SiteRole();
                    role.LoadFromReader(reader);
                }
            }

            return role;

        }
Beispiel #6
0
        public async Task<ISiteRole> FetchRole(
            int roleId, 
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            using (DbDataReader reader = await dbRoles.GetById(roleId, cancellationToken))
            {
                if (reader.Read())
                {
                    SiteRole role = new SiteRole();
                    role.LoadFromReader(reader);
                    return role;
                }
            }

            return null;
        }
Beispiel #7
0
        public async Task<ISiteRole> FetchRole(int siteId, string roleName)
        {
            if (multiTenantOptions.UseRelatedSitesMode) { siteId = multiTenantOptions.RelatedSiteId; }
            SiteRole role = null;

            using (DbDataReader reader = await dbRoles.GetByName(siteId, roleName))
            {
                while (reader.Read())
                {
                    role = new SiteRole();
                    role.LoadFromReader(reader);
                }
            }

            return role;

        }
Beispiel #8
0
        public IList<ISiteRole> GetRolesUserIsNotIn(
            int siteId,
            int userId)
        {
            if (multiTenantOptions.UseRelatedSitesMode) { siteId = multiTenantOptions.RelatedSiteId; }
            IList<ISiteRole> roles = new List<ISiteRole>();
            using (DbDataReader reader = dbRoles.GetRolesUserIsNotIn(siteId, userId))
            {
                SiteRole role = new SiteRole();
                role.LoadFromReader(reader);

                roles.Add(role);
            }
            return roles;
        }
Beispiel #9
0
        public async Task<IList<ISiteRole>> GetRolesBySite(
            int siteId,
            string searchInput,
            int pageNumber,
            int pageSize)
        {
            if (multiTenantOptions.UseRelatedSitesMode) { siteId = multiTenantOptions.RelatedSiteId; }

            IList<ISiteRole> roles = new List<ISiteRole>();
            using (DbDataReader reader = dbRoles.GetPage(siteId, searchInput, pageNumber, pageSize))
            {
                while (reader.Read())
                {
                    SiteRole role = new SiteRole();
                    role.LoadFromReader(reader);
                    role.MemberCount = Convert.ToInt32(reader["MemberCount"]);

                    roles.Add(role);
                }
            }

            return roles;

        }