Ejemplo n.º 1
0
        public TUser GetUserById(string userId)
        {
            TUser  user        = null;
            string commandText = "Select * from AspNetUsers where Id = @id";
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@id", userId }
            };

            DataTable dt1 = mDB.QueryDataSet(commandText, parameters).ZGetTable(0);

            if (dt1.ZGetRowsCount() == 1)
            {
                DataRow dr1 = dt1.Rows[0];
                user                      = (TUser)Activator.CreateInstance(typeof(TUser));
                user.Id                   = dr1.ZFetchString("Id");
                user.UserName             = dr1.ZFetchString("UserName");
                user.PasswordHash         = dr1.ZFetchString("PasswordHash");
                user.SecurityStamp        = dr1.ZFetchString("SecurityStamp");
                user.Email                = dr1.ZFetchString("Email");
                user.EmailConfirmed       = dr1.ZFetchBoolean("EmailConfirmed", false);
                user.PhoneNumber          = dr1.ZFetchString("PhoneNumber");
                user.PhoneNumberConfirmed = dr1.ZFetchBoolean("PhoneNumberConfirmed", false);
                user.LockoutEnabled       = dr1.ZFetchBoolean("LockoutEnabled", false);
                user.LockoutEndDateUtc    = dr1.ZFetchDateTime("LockoutEndDateUtc", DateTime.UtcNow);
                user.AccessFailedCount    = dr1.ZFetchInt("AccessFailedCount", 0);
            }
            return(user);
        }
Ejemplo n.º 2
0
        public List <string> FindByUserId(string userId)
        {
            List <string> roles       = new List <string>();
            string        commandText = "Select AspNetRoles.Name from AspNetUserRoles, AspNetRoles where AspNetUserRoles.UserId = @userId and AspNetUserRoles.RoleId = AspNetRoles.Id";
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@userId", userId);

            DataTable dt1 = mDB.QueryDataSet(commandText, parameters).ZGetTable(0);

            foreach (DataRow dr1 in dt1.Rows)
            {
                roles.Add(dr1.ZFetchString(0));
            }
            return(roles);
        }
Ejemplo n.º 3
0
        public List <UserLoginInfo> FindByUserId(string userId)
        {
            List <UserLoginInfo> logins            = new List <UserLoginInfo>();
            string commandText                     = "Select * from AspNetUserLogins where UserId = @userId";
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@userId", userId }
            };

            DataTable dt1 = mDB.QueryDataSet(commandText, parameters).ZGetTable(0);

            foreach (DataRow dr1 in dt1.Rows)
            {
                var login = new UserLoginInfo(dr1.ZFetchString("LoginProvider"), dr1.ZFetchString("ProviderKey"));
                logins.Add(login);
            }
            return(logins);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a ClaimsIdentity instance given a userId
        /// </summary>
        /// <param name="userId">The user's id</param>
        /// <returns></returns>
        public ClaimsIdentity FindByUserId(string userId)
        {
            ClaimsIdentity claims                  = new ClaimsIdentity();
            string         commandText             = "Select * from AspNetUserClaims where UserId = @userId";
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@UserId", userId }
            };

            var t1 = mDB.QueryDataSet(commandText, parameters).ZGetTable(0);

            foreach (DataRow row in t1.Rows)
            {
                Claim claim = new Claim(row.ZFetchString("ClaimType"), row.ZFetchString("ClaimValue"));
                claims.AddClaim(claim);
            }

            return(claims);
        }