public async Task <UserSearchResponse> UserSearch(UserSearchRequest request, SystemSession session) { var serviceRequest = new UserSearchQuery { Query = request.Query, Cursor = request.Cursor, Limit = request.Limit }; var response = await Task.Factory.StartNew(() => Client.SearchService.userSearch(serviceRequest, session.GetSession())).ConfigureAwait(false); var result = new UserSearchResponse { Cursor = response.Cursor, Limit = response.Limit, Count = response.Count, User = response.Users != null?response.Users.Select(x => new UserInformationBaseExtendedResponse { FirstName = x.UserInfoPerson.FirstName, LastName = x.UserInfoPerson.LastName, Image = x.UserInfo.Picture, Title = x.UserInfo.Title, UserId = Convert.ToInt32(x.UserInfoPerson.UserId), UserName = x.UserName, UserTypeId = (SystemUserType)x.UserInfo.UserTypeId }) : null }; return(result); }
public async Task <IHttpActionResult> SearchUsersAsync([FromUri] UserSearchRequest request) { request = request ?? new UserSearchRequest(); var result = new UserSearchResponse(); var query = UserManager.Users; if (request.Keyword != null) { query = query.Where(u => u.UserName.Contains(request.Keyword)); } result.TotalCount = query.Count(); var users = query.OrderBy(x => x.UserName) .Skip(request.SkipCount) .Take(request.TakeCount) .ToArray(); var extendedUsers = new List <ApplicationUserExtended>(); foreach (var user in users) { var extendedUser = await GetUserExtended(user.UserName, UserDetails.Reduced); extendedUsers.Add(extendedUser); } result.Users = extendedUsers.ToArray(); return(Ok(result)); }
public async Task <UserSearchResponse[]> SearchAsync(UserSearchOptions options) { string url = apiUrl + USER_URL + options.GetSearchPartAddress(); string json = await GetSearchResponseAsync(url); return(UserSearchResponse.FromJson(json)); }
public IActionResult LdapUserSearch([FromBody] UserSearchAttributes body) { var configuration = LdapPlugin.Instance.Configuration; configuration.LdapSearchAttributes = body.LdapSearchAttributes; configuration.EnableCaseInsensitiveUsername = body.EnableCaseInsensitiveUsername; LdapPlugin.Instance.UpdateConfiguration(configuration); var response = new UserSearchResponse(); if (string.IsNullOrEmpty(body.TestSearchUsername)) { return(Ok(response)); } try { var user = _ldapAuthenticationProvider.LocateLdapUser(body.TestSearchUsername); response.LocatedDn = user?.Dn; } catch (AuthenticationException e) { return(Unauthorized(new LdapTestErrorResponse(e.Message))); } return(Ok(response)); }
public async Task <UserSearchResponse> SearchUsersAsync(UserSearchRequest request) { request = request ?? new UserSearchRequest(); var result = new UserSearchResponse(); using (var userManager = _userManagerFactory()) { var query = userManager.Users; if (request.Keyword != null) { query = query.Where(u => u.UserName.Contains(request.Keyword)); } result.TotalCount = query.Count(); var users = query.OrderBy(x => x.UserName) .Skip(request.SkipCount) .Take(request.TakeCount) .ToArray(); var extendedUsers = new List <ApplicationUserExtended>(); foreach (var user in users) { var extendedUser = await FindByNameAsync(user.UserName, UserDetails.Reduced); extendedUsers.Add(extendedUser); } result.Users = extendedUsers.ToArray(); return(result); } }
public UserSearchResponse Search(UserSearchRequest request) { var response = new UserSearchResponse(); response.List = _facade.Search(request.Filter, request.PaginationInfo); return(response); }
public virtual async Task <UserSearchResponse> SearchUsersAsync(UserSearchRequest request) { request = request ?? new UserSearchRequest(); var result = new UserSearchResponse(); var users = new AccountEntity[] { }; using (var repository = _platformRepository()) { repository.DisableChangesTracking(); var query = repository.Accounts; if (request.Keyword != null) { query = query.Where(u => u.UserName.Contains(request.Keyword)); } if (!string.IsNullOrEmpty(request.MemberId)) { //Find all accounts with specified memberId query = query.Where(u => u.MemberId == request.MemberId); } else if (!request.MemberIds.IsNullOrEmpty()) { query = query.Where(u => request.MemberIds.Contains(u.MemberId)); } if (request.AccountTypes != null && request.AccountTypes.Any()) { query = query.Where(x => request.AccountTypes.Contains(x.UserType)); } result.TotalCount = await query.CountAsync(); users = await query.OrderBy(x => x.UserName) .Skip(request.SkipCount) .Take(request.TakeCount) .ToArrayAsync(); } var extendedUsers = new List <ApplicationUserExtended>(); foreach (var user in users) { var extendedUser = await FindByNameAsync(user.UserName, UserDetails.Reduced); if (extendedUser != null) { extendedUsers.Add(extendedUser); } } result.Users = extendedUsers.ToArray(); return(result); }
public UserSearchResponse GetUserSearchByNameAndFilter(UserSearchRequest request) { var response = new UserSearchResponse(); var query = new GetUsersBySearchCriteriaQuery(request.SearchText, request.RoleFilter); var result = this._repository.ExecuteQuery(query); response.Merge(result); if (result.Status == Status.Success) response.Values = result.Values; return response; }
public async Task AddGoogleIdToProfileProperty(UserSearchResponse user, string googleId, bool isAdmin) { List <UserProfileProperty> googleIdPP = new List <UserProfileProperty> { new UserProfileProperty { UserId = user.UserId, Value = googleId, ProfilePropertyName = "GoogleId" } }; UserProfileUpdater userProfileUpdater = new UserProfileUpdater(Cache, BudgeterLock, UserContext); await userProfileUpdater.UpdateUserProfileProperties(googleIdPP, isAdmin); }
public async Task <UserSearchResponse> SearchForPlayer(String username) { var response = new UserSearchResponse(); var user = await _UserRepo.GetPlayerByUsername(username); if (user == null) { user = await CreateNewUser(username); response.WasCreated = user != null; } else { response.WasCreated = false; } response.User = user; return(response); }
public virtual async Task <UserSearchResponse> SearchUsersAsync(UserSearchRequest request) { request = request ?? new UserSearchRequest(); var result = new UserSearchResponse(); var users = new AccountEntity[] { }; using (var repository = _platformRepository()) { repository.DisableChangesTracking(); var query = repository.Accounts; if (request.Keyword != null) { query = query.Where(u => u.UserName.Contains(request.Keyword)); } if (!string.IsNullOrEmpty(request.MemberId)) { //Find all accounts with specified memberId query = query.Where(u => u.MemberId == request.MemberId); } else if (!request.MemberIds.IsNullOrEmpty()) { query = query.Where(u => request.MemberIds.Contains(u.MemberId)); } if (request.AccountTypes != null && request.AccountTypes.Any()) { query = query.Where(x => request.AccountTypes.Contains(x.UserType)); } if (request.ModifiedSinceDate != null && request.ModifiedSinceDate != default(DateTime)) { query = query.Where(x => x.ModifiedDate > request.ModifiedSinceDate); } result.TotalCount = await query.CountAsync(); var sortInfos = request.SortInfos; if (sortInfos.IsNullOrEmpty()) { sortInfos = new[] { new SortInfo { SortColumn = "UserName", SortDirection = SortDirection.Descending } }; } query = query.OrderBySortInfos(sortInfos).ThenBy(x => x.Id); users = await query.Skip(request.SkipCount) .Take(request.TakeCount) .ToArrayAsync(); } var extendedUsers = new List <ApplicationUserExtended>(); var userDetail = EnumUtility.SafeParse(request.ResponseGroup, UserDetails.Full); if (userDetail == UserDetails.Info) { extendedUsers = users.Select(x => new ApplicationUser().ToCoreModel(x, _permissionScopeService)).ToList(); } else { foreach (var user in users) { var extendedUser = await FindByNameAsync(user.UserName, UserDetails.Reduced); if (extendedUser != null) { extendedUsers.Add(extendedUser); } } } result.Users = extendedUsers.ToArray(); return(result); }
public async Task <int> FindExistingUserOrRegister(GoogleUserProfile googleUser, bool isAdmin) { //Search for user by GoogleId PP var searchLogic = new SearchLogic(Cache, UserContext); var search = new UserSearch { SearchText = googleUser.Id, ProfilePropertyName = "GoogleId" }; Page <UserSearchResponse> searchResponse = await searchLogic.Search(search); if (searchResponse != null && searchResponse.Records != null && searchResponse.Records.Count > 0) { return(searchResponse.Records.Select(x => x.UserId).FirstOrDefault()); } else { //Search for user by Google Email as Username var usernameSearch = new UserSearch { SearchText = googleUser.Email, SearchUsername = true }; searchResponse = await searchLogic.Search(usernameSearch); } if (searchResponse != null && searchResponse.Records != null && searchResponse.Records.Count > 0) { UserSearchResponse user = searchResponse.Records.FirstOrDefault(); await AddGoogleIdToProfileProperty(user, googleUser.Id, isAdmin); return(user.UserId); } else { //Search for user by Google Email as Email PP var emailSearch = new UserSearch { SearchText = googleUser.Email, ProfilePropertyName = "Email" }; searchResponse = await searchLogic.Search(emailSearch); } if (searchResponse != null && searchResponse.Records != null && searchResponse.Records.Count > 0) { UserSearchResponse user = searchResponse.Records.FirstOrDefault(); await AddGoogleIdToProfileProperty(user, googleUser.Id, isAdmin); return(user.UserId); } else { //User does not exist, so Register them return(await RegisterGoogleUser(googleUser, isAdmin)); } }
public async Task<IHttpActionResult> SearchUsersAsync([FromUri] UserSearchRequest request) { request = request ?? new UserSearchRequest(); var result = new UserSearchResponse(); var query = UserManager.Users; if (request.Keyword != null) { query = query.Where(u => u.UserName.Contains(request.Keyword)); } result.TotalCount = query.Count(); var users = query.OrderBy(x => x.UserName) .Skip(request.SkipCount) .Take(request.TakeCount) .ToArray(); var extendedUsers = new List<ApplicationUserExtended>(); foreach (var user in users) { var extendedUser = await GetUserExtended(user.UserName, UserDetails.Reduced); extendedUsers.Add(extendedUser); } result.Users = extendedUsers.ToArray(); return Ok(result); }
public async Task <UserSearchResponse> SearchUsersAsync(UserSearchRequest request) { request = request ?? new UserSearchRequest(); var result = new UserSearchResponse(); using (var repository = _platformRepository()) { var query = repository.Accounts.Where(x => !x.Deleted); // PS +Deleted if (request.Keyword != null) { query = query.Where(u => u.DisplayName.Contains(request.Keyword) || u.UserName.Contains(request.Keyword)); } if (!string.IsNullOrEmpty(request.MemberId)) { //Find all accounts with specified memberId query = query.Where(u => u.MemberId == request.MemberId); } if (request.AccountTypes != null && request.AccountTypes.Any()) { query = query.Where(x => request.AccountTypes.Contains(x.UserType)); } var sortInfos = request.SortInfos; if (sortInfos.IsNullOrEmpty()) { sortInfos = new[] { new SortInfo { SortColumn = "Name" } }; } query = query.OrderBySortInfos(sortInfos); result.TotalCount = query.Count(); var users = query.Skip(request.SkipCount) .Take(request.TakeCount) .ToArray(); var extendedUsers = new List <ApplicationUserExtended>(); foreach (var user in users) { ApplicationUserExtended extendedUser; if (string.IsNullOrEmpty(user.UserName)) // PS: Если пользователь создан только для входа на кассу { extendedUser = await FindByIdAsync(user.Id, UserDetails.Reduced); } else { extendedUser = await FindByNameAsync(user.UserName, UserDetails.Reduced); } if (extendedUser != null) { extendedUsers.Add(extendedUser); } } result.Users = extendedUsers.ToArray(); return(result); } }