public async Task <SearchResult <UserInfo> > SearchAsync(UserSearchRequest request) { var result = await _client.SearchAsync <UserInfo>(descriptor => descriptor .Index(nameof(UserInfo).ToLowerInvariant()) .Type(nameof(UserInfo)) .Query(BuildQuery) .From(request.Offset) .Size(request.Limit)); return(new SearchResult <UserInfo> { Items = result.Documents, Total = (int)result.Total }); QueryContainer BuildQuery(QueryContainerDescriptor <UserInfo> q) { var queries = new List <QueryContainer>(); if (request.MinRating != null) { queries.Add(q.Range(d => d .Field(t => t.Rating) .GreaterThanOrEquals((double)request.MinRating.Value))); } if (queries.Count > 0) { return(q.Bool(b => b.Must(queries.ToArray()))); } return(q.MatchAll()); } }
public ActionResult Create(UserSearchRequestsViewModel model) { if (ModelState.IsValid) { if (User.Identity.GetUserId() != null) { var searchRequest = new UserSearchRequest { RequestKeyword = model.RequestKeyword, UserID = User.Identity.GetUserId(), RequestDateTime = DateTime.Now }; db.UserSearchRequest.Add(searchRequest); db.SaveChanges(); String keyword = model.RequestKeyword; TempData["keyword"] = keyword; int requestId = searchRequest.RequestId; TempData["RequestId"] = requestId; return(RedirectToAction("Index", "RequestResults")); } else { String keyword = model.RequestKeyword; TempData["keyword"] = keyword; return(RedirectToAction("Index", "RequestResults")); } } return(View(model)); }
public IEnumerable <Model.User> Get(UserSearchRequest request) { var query = _context.Users.AsQueryable(); if (!string.IsNullOrWhiteSpace(request?.FirstName)) { query = query.Where(x => x.FirstName.Contains(request.FirstName)); } if (!string.IsNullOrWhiteSpace(request?.LastName)) { query = query.Where(x => x.LastName.Contains(request.LastName)); } if (!string.IsNullOrWhiteSpace(request?.Phone)) { query = query.Where(x => x.Phone.Contains(request.Phone)); } if (!string.IsNullOrWhiteSpace(request?.Email)) { query = query.Where(x => x.Email.Contains(request.Email)); } return(_mapper.Map <IEnumerable <Model.User> >(query.Where(x => x.RoleId == 2).ToList())); }
public Task SaveLastSearchAsync(UserSearchRequest request, string userId) { var searchEntity = _mapper.Map <UserSearchEntity>(request); searchEntity.UserId = userId; return(_historyRepository.SaveLastSearchAsync(searchEntity)); }
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); } }
private async void BtnSearch_Click(object sender, EventArgs e) { UserSearchRequest request = new UserSearchRequest { FirstName = txtFirstName.Text, LastName = txtLastName.Text }; var list = await _userService.GetAll <List <User> >(request); List <User> result = new List <User>(); foreach (var item in list) { foreach (var role in item.UserRoles) { if (role.Role.Name == "Client") { result.Add(item); } } } dgvClients.AutoGenerateColumns = false; dgvClients.DataSource = result; if (result.Count == 0) { MessageBox.Show("There are no results for this search", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public IEnumerable <AppUser> GetByCriteria(UserSearchRequest request) { var users = _repository.GetAll(); if (!string.IsNullOrWhiteSpace(request.Name)) { users = users.Where(x => x.Name.ToLower().Contains(request.Name.ToLower())); } if (!string.IsNullOrWhiteSpace(request.LastName)) { users = users.Where(x => x.LastName.ToLower().Contains(request.LastName.ToLower())); } if (!string.IsNullOrWhiteSpace(request.Email)) { users = users.Where(x => x.Email.ToLower().Contains(request.Email.ToLower())); } if (request.Role.HasValue) { users = users.Where(x => x.UserRole == request.Role); } return(users); }
public IList <UserDto> Get(UserSearchRequest search) { var query = _context.Users.AsQueryable(); if (!string.IsNullOrWhiteSpace(search?.FirstName)) { query = query.Where(x => x.FirstName == search.FirstName); } if (!string.IsNullOrWhiteSpace(search?.LastName)) { query = query.Where(x => x.LastName == search.LastName); } if (!string.IsNullOrWhiteSpace(search?.UserName)) { query = query.Where(x => x.UserName.Contains(search.UserName)); } if (!string.IsNullOrWhiteSpace(search?.Email)) { query = query.Where(x => x.Email == search.Email); } var entities = query.ToList(); var result = _mapper.Map <IList <UserDto> >(entities.Where(x => 1 == 1)); return(result); }
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 object Get(UserSearchRequest request) { var context = TepWebContext.GetWebContext(PagePrivileges.UserView); context.Open(); context.LogInfo(this, string.Format("/user/search GET")); EntityList <UserTep> users = new EntityList <UserTep> (context); users.AddSort("Identifier", SortDirection.Ascending); // Load the complete request HttpRequest httpRequest = HttpContext.Current.Request; OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine; string format; if (Request.QueryString ["format"] == null) { format = "atom"; } else { format = Request.QueryString ["format"]; } Type responseType = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose); IOpenSearchResultCollection osr = ose.Query(users, httpRequest.QueryString, responseType); OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(users, osr); context.Close(); return(new HttpResult(osr.SerializeToString(), osr.ContentType)); }
public ActionResult <UserListResponse> Search([FromQuery] UserSearchRequest searchRequest) { var users = _users.Search(searchRequest); var userCount = _users.Count(searchRequest); return(UserListResponse.Create(searchRequest, users, userCount)); }
public async Task Init() { UserSearchRequest request = new UserSearchRequest { Username = APIService.Username }; var list = await _userService.GetAll <List <User> >(request); var client = list[0]; if (AppointmentList.Count > 0) { AppointmentList.Clear(); } AppointmentSearchRequest request2 = new AppointmentSearchRequest { UserID = client.UserID }; var appointments = await _appointmentService.GetAll <List <Appointment> >(request2); foreach (var appointment in appointments) { AppointmentList.Add(appointment); } if (AppointmentList.Count == 0) { await Application.Current.MainPage.DisplayAlert("Warning", "You don't have any appointments yet.", "OK"); } }
private async Task LoadUsers() { UserSearchRequest request = new UserSearchRequest { Username = txtSearch.Text }; var id = cmbType.SelectedValue; if (int.TryParse(id.ToString(), out int ID)) { request.UserTypeId = ID; } var list = await _serviceUser.GetAll <List <User> >(request); List <frmUserSearchVM> vm = new List <frmUserSearchVM>(); foreach (var item in list) { frmUserSearchVM ni = new frmUserSearchVM { Email = item.Email, FirstName = item.FirstName, LastName = item.LastName, Id = item.Id, Phone = item.Phone, Username = item.Username, UserType = item.UserType.Type }; vm.Add(ni); } dgvUser.DataSource = vm; }
public List <Model.User> GetAll(UserSearchRequest search) { var query = _context.Users.AsQueryable(); if (!string.IsNullOrWhiteSpace(search?.Username)) { query = query.Where(x => x.Username == search.Username); } if (!string.IsNullOrWhiteSpace(search?.FirstName)) { query = query.Where(x => x.FirstName == search.FirstName); } if (!string.IsNullOrWhiteSpace(search?.LastName)) { query = query.Where(x => x.LastName == search.LastName); } // var entities = query.Where(x => x.RoleId == 1).ToList(); var entities = query.Where(x => x.RoleId == 2 || x.RoleId == 3).ToList(); var result = _mapper.Map <List <Model.User> >(entities); return(result); }
async Task Update() { UserSearchRequest request = new UserSearchRequest { Username = APIService.Username }; var list = await _service.GetAll <List <eDrivingSchool.Model.User> >(request); var id = list[0].Id; var user = list[0]; UserInsertRequest request2 = new UserInsertRequest { Username = user.Username, FirstName = user.FirstName, LastName = user.LastName, Email = Email, Phone = Phone, Address = user.Address, Birthdate = user.Birthdate, JMBG = user.JMBG, RoleId = user.RoleId, }; var returned_user = await _service.Update <eDrivingSchool.Model.User>(id, request2); Application.Current.MainPage = new YourProfilePage(); }
public async Task <IHttpActionResult> Search(UserSearchRequest req) { if (req == null || req.Prefix == null || req.Max < 1) { return(BadRequest()); } using (var db = new ZapContext()) { var users = await db.Users .Where(u => u.Name.Contains(req.Prefix)) .OrderByDescending(u => u.DateLastActivity) .Take(req.Max) .Select(u => new UserResultInfo() { UserName = u.Name, UserAppId = u.AppId, ProfileImageVersion = u.ProfileImage != null ? u.ProfileImage.Version : 0 }).ToListAsync().ConfigureAwait(false); return(Ok(new UserSearchResponse() { Users = users })); } }
private async Task <bool> ExistsToUpdate(UserSearchRequest search) { var queryFilter = GetQueryFilterForId(search); var result = await _userDataAccess.AnyAsync(queryFilter); return(result); }
public async Task <UserListViewModel> GetPageList(UserSearchRequest search) { var users = _users.AsNoTracking().OrderBy(a => a.UserName).AsQueryable(); if (search.RoleId.HasValue) { users = users.Include(a => a.Roles) .Where(a => a.Roles.Any(r => r.RoleId == search.RoleId.Value)) .AsQueryable(); } if (search.UserName.HasValue()) { users = users.Where(a => a.UserName.Contains(search.UserName)); } var query = await users .Skip((search.PageIndex - 1) * 10).Take(10).ProjectTo <UserViewModel>(_mappingEngine) .ToListAsync(); return(new UserListViewModel { SearchRequest = search, Users = query }); }
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 <bool> Exists(UserSearchRequest search) { var queryFilter = GetQueryFilter(search); var result = await _userDataAccess.AnyAsync(queryFilter); return(result); }
public List <UserInfo> GetUsers([FromQuery] UserSearchRequest request) { var query = _userService.GetUsers().AsQueryable(); if (request.Username != null || request.FirstName != null || request.LastName != null || request.Username != null) { query = query.Where(x => x.FirstName.ToLower().StartsWith(request.FirstName) || x.LastName.ToLower().StartsWith(request.LastName) || x.Email.ToLower().StartsWith(request.Email) || x.Username.ToLower().StartsWith(request.Username) ); } var users = query .OrderByDescending(x => x.JoinDate) .Select(x => new UserInfo { Id = x.Id, Email = x.Email, FirstName = x.FirstName, JoinDate = x.JoinDate, LastName = x.LastName, Username = x.Username, Roles = string.Join(",", x.UsersRoles.Select(r => r.Role.Name)) }) .ToList(); return(users); }
private async void btnShowUsers_Click(object sender, EventArgs e) { var search = new UserSearchRequest() { Name = searchBox.Text }; var result = await _apiService.Get <List <Model.Visitor> >(search); var listUR = await _apiServiceUR.Get <List <Model.VisitorRole> >(null); List <Model.Visitor> listV = new List <Model.Visitor>(); int c = 0; foreach (var r in result) { foreach (var ur in listUR) { if (r.UserID == ur.UserId && ur.RoleId == 2) { c++; } } if (c > 0) { listV.Add(r); } c = 0; } dgvUsers.AutoGenerateColumns = false; dgvUsers.DataSource = listV; }
public List <Model.Visitor> Get(UserSearchRequest search) { var query = _context.User.AsQueryable(); if (!string.IsNullOrWhiteSpace(search.Name)) { query = query.Where(q => q.Name.StartsWith(search.Name)); } if (!string.IsNullOrWhiteSpace(search.Surname)) { query = query.Where(q => q.Surname.StartsWith(search.Surname)); } if (!string.IsNullOrWhiteSpace(search.Username)) { query = query.Where(q => q.Username.StartsWith(search.Username)); } var list = query.ToList(); List <Model.Visitor> rez = _mapper.Map <List <Model.Visitor> >(list); foreach (var item in rez) { foreach (var s in _context.Visit.ToList()) { if (item.UserID == s.UserId) { item.NumberOfVisits++; } } } return(rez); }
public async Task <FabricIdentityUserResponse> Search(string clientId, IEnumerable <string> userIds) { var userIdList = userIds.ToList(); if (userIdList.Count == 0) { return(new FabricIdentityUserResponse { Results = new List <UserSearchResponse>(), HttpStatusCode = HttpStatusCode.OK }); } // TODO: clean this up / move to config var settings = _appConfiguration.IdentityServerConfidentialClientSettings; var tokenUriAddress = $"{settings.Authority}connect/token"; var tokenClient = new TokenClient(tokenUriAddress, "fabric-authorization-client", settings.ClientSecret); var accessTokenResponse = await tokenClient.RequestClientCredentialsAsync(IdentityScopes.SearchUsersScope).ConfigureAwait(false); var httpClient = new HttpClientFactory( tokenUriAddress, "fabric-authorization-client", settings.ClientSecret, null, null).CreateWithAccessToken(new Uri(settings.Authority), accessTokenResponse.AccessToken); var request = new UserSearchRequest { ClientId = clientId, UserIds = userIdList }; _logger.Debug($"Invoking Fabric.Identity endpoint {httpClient.BaseAddress}"); var response = await httpClient.PostAsync("api/users", new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json")); var results = new List <UserSearchResponse>(); var responseContent = response.Content == null ? string.Empty : await response.Content.ReadAsStringAsync(); if (response.StatusCode != HttpStatusCode.OK) { _logger.Error($"Response status code from Fabric.Identity api/users => {response.StatusCode}"); _logger.Error($"Response content from Fabric.Identity api/users => {responseContent}"); } else { results = JsonConvert.DeserializeObject <List <UserSearchResponse> >(responseContent); _logger.Debug($"Fabric.Identity /users results: {results}"); } return(new FabricIdentityUserResponse { HttpStatusCode = response.StatusCode, Results = results }); }
private async void FormUsers_Load(object sender, EventArgs e) { this.dgvUsers.DoubleBuffered(true); UserSearchRequest userSearchRequest = new UserSearchRequest(); userSearchRequest = ApplyDefaultSearchValues(userSearchRequest) as UserSearchRequest; await LoadUsers(userSearchRequest); }
public async Task <IPagedList <ApplicationUserDto> > GetPagedAsync(UserSearchRequest search) { var list = await _userRepo.GetPagedAsync(search, search.searchTerm); var dtoList = PagedList <ApplicationUserDto> .Map <ApplicationUser>(_mapper, list); return(dtoList); }
public UserSearchResponse Search(UserSearchRequest request) { var response = new UserSearchResponse(); response.List = _facade.Search(request.Filter, request.PaginationInfo); return(response); }
public async Task <ResponseList <UserResponse> > Search(UserSearchRequest request) { int skip = request.PageNumber * request.PageSize; (var users, int total) = await _uow.Users.SearchUser(request.FullText, skip, request.PageSize, request.SortType, request.SortField); return(new ResponseList <UserResponse>(ResponseStatus.Ok, _mapService.MapUsers(users.ToList(), true), total)); }
private async Task LoadList(UserSearchRequest request) { var result = await userService.Get <List <MUser> >(request); dgvUsers.AutoGenerateColumns = false; dgvUsers.ReadOnly = true; dgvUsers.DataSource = result; }
public void PostSearchTest() { // TODO: add unit test for the method 'PostSearch' UserSearchRequest body = null; // TODO: replace null with proper value var response = instance.PostSearch(body); Assert.IsInstanceOf <UsersSearchResponse> (response, "response is UsersSearchResponse"); }
static void Main(string[] args) { const string consumerKey = "fCgzzKtIveNeZTVsD5wKE9VvT"; const string consumerSecret = "etwJ35k2eAnYkfKNeAEYZLE1d66bO0G1X389ZC2GNzTkYJMhtV"; const string accessToken = "1599259255-qauXuOwgdOHs6tlIZe78E55GaY4hGstMxZ6QmWo"; const string accessTokenSecret = "gFYhri2Mtgb7Dgdcv23ZA9s6RfAcNmWJpRdL1sZM1qpBq"; ApiKey key = new ApiKey(consumerKey, consumerSecret, accessToken, accessTokenSecret); UserSearchRequest userSearchRequest = new UserSearchRequest(key, "BennyPeake"); userSearchRequest.SendRequest(); Thread.Sleep(5000); }
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; }
/// <summary> /// Search users by keyword /// </summary> /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="request">Search parameters.</param> /// <returns>UserSearchResponse</returns> public UserSearchResponse SecuritySearchUsersAsync(UserSearchRequest request) { ApiResponse<UserSearchResponse> localVarResponse = SecuritySearchUsersAsyncWithHttpInfo(request); return localVarResponse.Data; }
/// <summary> /// Search users by keyword /// </summary> /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="request">Search parameters.</param> /// <returns>Task of ApiResponse (UserSearchResponse)</returns> public async System.Threading.Tasks.Task<ApiResponse<UserSearchResponse>> SecuritySearchUsersAsyncAsyncWithHttpInfo(UserSearchRequest request) { // verify the required parameter 'request' is set if (request == null) throw new ApiException(400, "Missing required parameter 'request' when calling VirtoCommercePlatformApi->SecuritySearchUsersAsync"); var localVarPath = "/api/platform/security/users"; var localVarPathParams = new Dictionary<string, string>(); var localVarQueryParams = new Dictionary<string, string>(); var localVarHeaderParams = new Dictionary<string, string>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary<string, string>(); var localVarFileParams = new Dictionary<string, FileParameter>(); object localVarPostBody = null; // to determine the Content-Type header string[] localVarHttpContentTypes = new string[] { "application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded" }; string localVarHttpContentType = ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header string[] localVarHttpHeaderAccepts = new string[] { "application/json", "text/json", "application/xml", "text/xml" }; string localVarHttpHeaderAccept = ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json localVarPathParams.Add("format", "json"); if (request.GetType() != typeof(byte[])) { localVarPostBody = ApiClient.Serialize(request); // http body (model) parameter } else { localVarPostBody = request; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (localVarStatusCode >= 400 && (localVarStatusCode != 404 || Configuration.ThrowExceptionWhenStatusCodeIs404)) throw new ApiException(localVarStatusCode, "Error calling SecuritySearchUsersAsync: " + localVarResponse.Content, localVarResponse.Content); else if (localVarStatusCode == 0) throw new ApiException(localVarStatusCode, "Error calling SecuritySearchUsersAsync: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage); return new ApiResponse<UserSearchResponse>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (UserSearchResponse)ApiClient.Deserialize(localVarResponse, typeof(UserSearchResponse))); }
public async Task<IHttpActionResult> SearchUsersAsync(UserSearchRequest request) { var result = await _securityService.SearchUsersAsync(request); return Ok(result); }
/// <summary> /// Search users by keyword /// </summary> /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="request">Search parameters.</param> /// <returns>Task of UserSearchResponse</returns> public async System.Threading.Tasks.Task<UserSearchResponse> SecuritySearchUsersAsyncAsync(UserSearchRequest request) { ApiResponse<UserSearchResponse> localVarResponse = await SecuritySearchUsersAsyncAsyncWithHttpInfo(request); return localVarResponse.Data; }