コード例 #1
0
    public ActionResult LogedInUsers()
    {
        var    identity = (ClaimsPrincipal)Thread.CurrentPrincipal;
        string userName = identity.Claims.Where(c => c.Type == ClaimTypes.Name)
                          .Select(c => c.Value).SingleOrDefault();

        var loginUser = reader.GetUserAccountDetail(userName).Result;

        Users users = new Users();

        foreach (var user in loginUser.Data)
        {
            users = new Users()
            {
                ID       = user.ID,
                Username = user.Username,
                RoleID   = user.RoleID,
                Email    = user.Email,
                FullName = user.FullName,
                Roles    = new Roles()
                {
                    ID          = user.Roles.ID,
                    Name        = user.Roles.Name,
                    Description = user.Roles.Description,
                }
            };
        }
        return(PartialView(users));
    }
コード例 #2
0
        public async Task <Users> UserIdentityAsync()
        {
            var    identity = (ClaimsPrincipal)Thread.CurrentPrincipal;
            string userName = identity.Claims.Where(c => c.Type == ClaimTypes.Name)
                              .Select(c => c.Value).SingleOrDefault();

            var loginUser = await reader.GetUserAccountDetail(userName);

            Users users = new Users();

            foreach (var user in loginUser.Data)
            {
                users = new Users()
                {
                    ID       = user.ID,
                    Username = user.Username,
                    RoleID   = user.RoleID,
                    Email    = user.Email,
                    FullName = user.FullName,
                    Roles    = new Roles()
                    {
                        ID          = user.Roles.ID,
                        Name        = user.Roles.Name,
                        Description = user.Roles.Description,
                    }
                };
            }

            return(users);
        }