public List<NGUOIDUNGInfo> SelectPaging(int page, int pageSize, string role) { List<NGUOIDUNGInfo> lstItem = new List<NGUOIDUNGInfo>(); MembershipUserCollection userCollection = Membership.GetAllUsers(); foreach (MembershipUser user in userCollection) { var roleForUser = Roles.GetRolesForUser(user.UserName)[0]; if (role == "SuperAdmin") { if (roleForUser != "SuperAdmin") { NGUOIDUNGInfo userInfo = new NGUOIDUNGInfo { BaseInfo = new NGUOIDUNGBaseInfo { ID = (Guid)user.ProviderUserKey, UserName = user.UserName, Email = user.Email, Role = Roles.GetRolesForUser(user.UserName)[0] }, }; lstItem.Add(userInfo); } } else if (role == "Admin") { if (roleForUser != "SuperAdmin" && roleForUser != "Admin") { NGUOIDUNGInfo userInfo = new NGUOIDUNGInfo { BaseInfo = new NGUOIDUNGBaseInfo { ID = (Guid)user.ProviderUserKey, UserName = user.UserName, Email = user.Email, Role = Roles.GetRolesForUser(user.UserName)[0] }, }; lstItem.Add(userInfo); } } } TotalItem = lstItem.Count; if (pageSize > 0) { int startIndex, itemCount; startIndex = (page - 1) * pageSize; itemCount = pageSize; if (startIndex + itemCount > lstItem.Count) itemCount = lstItem.Count - startIndex; lstItem = lstItem.GetRange(startIndex, itemCount); } return lstItem; }
public List<NGUOIDUNGInfo> SelectAll(string role) { List<NGUOIDUNGInfo> lstItem = new List<NGUOIDUNGInfo>(); MembershipUserCollection userCollection = Membership.GetAllUsers(); foreach (MembershipUser user in userCollection) { var roleForUser = Roles.GetRolesForUser(user.UserName)[0]; if (role == "SuperAdmin") { if (roleForUser != "SuperAdmin") { NGUOIDUNGInfo userInfo = new NGUOIDUNGInfo { BaseInfo = new NGUOIDUNGBaseInfo { ID = (Guid)user.ProviderUserKey, UserName = user.UserName, Email = user.Email, Role = Roles.GetRolesForUser(user.UserName)[0] }, }; lstItem.Add(userInfo); } } else if (role == "Admin") { if (roleForUser != "SuperAdmin" && roleForUser != "Admin") { NGUOIDUNGInfo userInfo = new NGUOIDUNGInfo { BaseInfo = new NGUOIDUNGBaseInfo { ID = (Guid)user.ProviderUserKey, UserName = user.UserName, Email = user.Email, Role = Roles.GetRolesForUser(user.UserName)[0] }, }; lstItem.Add(userInfo); } } } TotalItem = lstItem.Count; return lstItem; }
public NGUOIDUNGInfo SelectByUserName(string username) { var user = Membership.GetUser(username); NGUOIDUNGInfo userInfo = new NGUOIDUNGInfo { BaseInfo = new NGUOIDUNGBaseInfo { ID = (Guid)user.ProviderUserKey, UserName = user.UserName, Email = user.Email, Role = Roles.GetRolesForUser(user.UserName)[0] }, }; TotalItem = 1; return userInfo; }
public List<NGUOIDUNGInfo> RetrieveByUserName(string username) { var user = Membership.GetUser(username); NGUOIDUNGInfo userInfo = new NGUOIDUNGInfo { BaseInfo = new NGUOIDUNGBaseInfo { ID = (Guid)user.ProviderUserKey, UserName = user.UserName, Email = user.Email } }; var lstItem = new List<NGUOIDUNGInfo>(); lstItem.Add(userInfo); TotalItem = 1; return lstItem; }