private List<UserViewModel> GetUserList() { MembershipUserCollection memCollection = Membership.GetAllUsers(); List<UserViewModel> users = new List<UserViewModel>(); foreach (MembershipUser user in memCollection) { UserViewModel item = new UserViewModel(); item.UserId = Guid.Parse(user.ProviderUserKey.ToString()); item.UserName = user.UserName; item.Role = Roles.GetRolesForUser(user.UserName)[0]; users.Add(item); } return users; }
public ActionResult UserListPartial() { List<UserViewModel> modelList = new List<UserViewModel>(); MembershipUserCollection memCollection = Membership.GetAllUsers(); foreach (MembershipUser user in memCollection) { UserProfile profile = UserProfile.GetProfile(user.UserName); if (profile.CompanyId == AuthenticationHelper.CompanyId.Value) { UserViewModel item = new UserViewModel(); item.UserId = Guid.Parse(user.ProviderUserKey.ToString()); item.UserName = user.UserName; item.FirstName = profile.FirstName; item.LastName = profile.LastName; item.PhoneNumber = profile.PhoneNumber; item.Email = profile.Email; item.CompanyId = profile.CompanyId; item.CompanyName = companyService.GetSingle(profile.CompanyId.ToString(), AuthenticationHelper.CompanyId.Value).Name; item.Role = Roles.GetRolesForUser(user.UserName)[0]; modelList.Add(item); } } return PartialView("_List", modelList); }