Exemplo n.º 1
0
        public List <UserViewModel> GetAllUsers()
        {
            var UserList    = new List <UserViewModel>();
            var userManager = MembershipTools.NewUserManager();

            List <ApplicationUser> list = userManager.Users.ToList();

            foreach (var item in list)
            {
                UserList.Add(new UserViewModel()
                {
                    Name           = item.Name,
                    SurName        = item.SurName,
                    Email          = item.Email,
                    UserName       = item.UserName,
                    ID             = item.Id,
                    RoleID         = item.Roles.First()?.RoleId,
                    EmailConfirmed = item.EmailConfirmed,
                    PhoneNumber    = item.PhoneNumber,
                    RegisterDate   = item.RegisterDate,
                    RoleName       = MembershipTools.GetRoleName(item.Roles.First()?.RoleId)
                });
            }

            return(UserList);
        }