/// <summary> /// 获取用户的信息 /// </summary> /// <returns></returns> public async Task <HeaderResult <List <UserDto> > > GetUserList(SearchUserDto input) { Expression <Func <UserInfo, bool> > where = e => e.IsDisable == false; if (!string.IsNullOrEmpty(input.SearchName)) { where = where.And(e => e.UserName.Contains(input.SearchName)); } if (!string.IsNullOrEmpty(input.SearchPwd)) { where = where.And(e => e.UserPhone.Contains(input.SearchPwd)); } var userList = await _userRepository.LoadEntityListAsync(where, e => e.UserName, "asc", input.PageIndex, input.Pagesize); var total = await _userRepository.GetEntitiesCountAsync(where); var userDtoList = userList.MapToList <UserInfo, UserDto>(); HeaderResult <List <UserDto> > result = new HeaderResult <List <UserDto> > { IsSucceed = true, Result = userDtoList, Total = total }; return(result); }
public static SearchUserDto Map(User from, int currentUerId) { if (from == null) { return(null); } var to = new SearchUserDto { Fullname = $"{from.FirstName} {from.LastName}", Id = from.Id, Bio = from.Bio, ProfilePic = from.ProfilePhotos.Where(x => x.IsCurrent == true).Count() == 0 ? (from.GenderId == 1 ? "default.jpg" : "default_female.png") : from.ProfilePhotos.Where(x => x.IsCurrent == true).FirstOrDefault().Url }; if (from.UserRelationsDesider.Any(x => x.InitiatorId == currentUerId)) { to.SocialStatus = from.UserRelationsDesider.FirstOrDefault(x => x.InitiatorId == currentUerId).SocialStatusId; to.Initiator = false; } else if (from.UserRelationsInitiator.Any(x => x.DesiderId == currentUerId && x.IsDeleted == false)) { to.SocialStatus = from.UserRelationsInitiator.FirstOrDefault(x => x.DesiderId == currentUerId && x.IsDeleted == false).SocialStatusId; to.Initiator = true; } else { to.SocialStatus = 0; //no relation to.Initiator = null; } return(to); }
public SearrchPagingDto GetList(SearchUserDto searchModel) { if (searchModel != null) { var result = _mapper.Map <SearchUserDto, SearrchPagingDto>(searchModel); var data = users.Take(searchModel.Take).Skip(searchModel.PageSize).ToList(); result.Data = _mapper.Map <List <User>, List <UserDto> >(data); result.TotalItems = users.Count(); return(result); } return(new SearrchPagingDto()); }
public PageResult <Users> SearchUsers(SearchUserDto model) { var users = _dbContext.Users.Where(x => x.IsEnable && !x.IsDelete); if (!string.IsNullOrWhiteSpace(model.Text)) { users = users.Where(x => x.UserName.Contains(model.Text) || x.NickName.Contains(model.Text)); } var result = users.Page(model.Page, model.Size); return(result); }
public async Task <IEnumerable <User> > SearchUsers(SearchUserDto searchUser) { var users = from user in _userManager.Users .Include(s => s.LibraryCard) .Where(u => u.UserRoles.Any(r => r.Role.Name == EnumRoles.Member.ToString())) select user; users = users .Where(s => s.Email == searchUser.Email || s.FirstName.Contains(searchUser.FirstName) || s.Lastname.Contains(searchUser.LastName)); return(await users.ToListAsync()); }
public async Task <ActionResult <List <SearchUserDto> > > FindUsers([FromBody] SearchUserCommand command) { string[] searchString = command.SearchString.Split(null); var firstPart = string.IsNullOrEmpty(searchString[0]) ? "" : searchString[0]; var secondPart = searchString.Length <= 1 ? "" : searchString[1]; List <User> users = _context.Users.Include(x => x.Gender).Include(x => x.City).ToList(); var usersOne = users.Where(x => x.FirstName.ToLower().StartsWith(firstPart.ToLower())).ToList(); var usersThree = users.Where(x => x.LastName.ToLower().StartsWith(firstPart.ToLower())).ToList(); var usersTwo = new List <User>(); var usersFour = new List <User>(); if (!string.IsNullOrEmpty(secondPart)) { usersTwo = users.Where(x => x.FirstName.ToLower().StartsWith(secondPart.ToLower())).ToList(); usersFour = users.Where(x => x.LastName.ToLower().StartsWith(secondPart.ToLower())).ToList(); } var allUsers = usersOne.Union(usersTwo).Union(usersThree).Union(usersFour).ToList(); var finalUsers = new List <SearchUserDto>(); if (allUsers.Count() == 0) { return(NotFound("No users found for this search string")); } else { foreach (var user in allUsers) { var usTemp = new SearchUserDto { City = _context.Cities.Find(user.CityId).Name, Email = user.Email, FirstLastName = user.FirstName + " " + user.LastName, Gender = _context.Genders.Find(user.GenderId).Name, IdUser = user.Iduser }; finalUsers.Add(usTemp); } finalUsers.OrderBy(x => x.FirstLastName); return(Ok(finalUsers)); } }
public async Task <HeaderResult <List <UserDto> > > WebApiClientBaseLocAsync() { SearchUserDto search = new SearchUserDto() { PageIndex = 1, Pagesize = 10, SearchPwd = "", SearchName = "" }; try { var userList = await _webApiClientBase.GetUserListAsync(search); return(userList); } catch (Exception e) { Console.WriteLine(e); throw; } }
public PaginationDto <UserDto> GetUsers(SearchUserDto dto) { var query = _dbContext.Users.Where(c => c.Type != Domain.Enumeration.UserType.Programmer); if (!string.IsNullOrEmpty(dto.PhoneNumber)) { query = query.Where(c => c.PhoneNumber.Contains(dto.PhoneNumber)); } if (!string.IsNullOrEmpty(dto.FullName)) { query = query.Where(c => c.FullName.Contains(dto.FullName)); } if (dto.Type.HasValue && dto.Type != 0) { query = query.Where(c => c.Type == dto.Type.Value); } IOrderedQueryable <User> orderedQery = query.OrderByDescending(c => c.RegisterDate); return(orderedQery.ToPaginated(dto).ToDto()); }
public async Task <HeaderResult <List <UserGroupDto> > > GetUserGroupList([FromBody] SearchUserDto input) { return(await _userAppService.GetUserGroupList(input)); }
public IActionResult Get([FromQuery] SearchUserDto searchModel) { var users = _userService.GetList(searchModel); return(Ok(users)); }
public PageResult <Users> SearchUsers([FromQuery] SearchUserDto model) { var result = _iUserService.SearchUsers(model); return(result); }
public List <UserDto> SearchUser(SearchUserDto request) { throw new NotImplementedException(); }