Exemplo n.º 1
0
        private SearchStatementModel PrepareSearchStatement(GridCommand command, UserSearchModel searchModel)
        {
            string whereStatement = string.Empty;

            IList <object> param = new List <object>();

            HqlStatementHelper.AddLikeStatement("Code", searchModel.Code, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param);
            HqlStatementHelper.AddLikeStatement("FirstName", searchModel.FirstName, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param);
            HqlStatementHelper.AddLikeStatement("LastName", searchModel.LastName, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("IsActive", searchModel.IsActive, "u", ref whereStatement, param);

            if (command.SortDescriptors.Count > 0)
            {
                if (command.SortDescriptors[0].Member == "LanguageDescription")
                {
                    command.SortDescriptors[0].Member = "Language";
                }
            }
            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

            SearchStatementModel searchStatementModel = new SearchStatementModel();

            searchStatementModel.SelectCountStatement = selectCountStatement;
            searchStatementModel.SelectStatement      = selectStatement;
            searchStatementModel.WhereStatement       = whereStatement;
            searchStatementModel.SortingStatement     = sortingStatement;
            searchStatementModel.Parameters           = param.ToArray <object>();

            return(searchStatementModel);
        }
Exemplo n.º 2
0
        public ActionResult List(GridCommand command, UserSearchModel searchModel)
        {
            SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);

            ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
            return(View());
        }
Exemplo n.º 3
0
        public IActionResult Grid(UserSearchModel model)
        {
            model = InitializeModel(model);
            var result = _employeeApiClient.GetUsers(model).Result;

            return(PartialView(result));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 取得使用者列表
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="pagination"></param>
        /// <returns></returns>
        public async Task <JsonResult> GetUserList(UserSearchModel searchModel, PaginationViewModel pagination)
        {
            ResWithPaginationViewModel res = new ResWithPaginationViewModel();

            try
            {
                var result = await _userService.GetUserList(searchModel, pagination);

                res.Data           = result.Data;
                res.Pagination     = result.Pagination;
                res.MinDateTime    = result.MinDateTime;
                res.MaxDateTime    = result.MaxDateTime;
                res.Success        = true;
                res.Message        = "取得權限管理列表成功";
                res.HttpStatusCode = System.Net.HttpStatusCode.OK;
                //await _backOperationService.CreateBackOperation(CurrendUserid, OperationName + "查詢", CurrendUserIp);
            }
            catch
            {
                res.Success        = false;
                res.Message        = "與伺服器連線發生錯誤";
                res.HttpStatusCode = System.Net.HttpStatusCode.InternalServerError;
            }
            res.ResponseTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public User Find(UserSearchModel user)
        {
            var builder = Builders <User> .Filter;
            var filter  = builder.Or(builder.Eq(m => m.UserCode, user.UserCode), builder.Eq(m => m.WxOpenId, user.WxOpenId));

            return(_mongoHelper.Find(filter));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Prepare user search model
        /// </summary>
        /// <param name="searchModel">User search model</param>
        /// <returns>User search model</returns>
        public virtual UserSearchModel PrepareUserSearchModel(UserSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            searchModel.UsernamesEnabled     = _userSettings.UsernamesEnabled;
            searchModel.AvatarEnabled        = _userSettings.AllowUsersToUploadAvatars;
            searchModel.DateOfBirthEnabled   = _userSettings.DateOfBirthEnabled;
            searchModel.CompanyEnabled       = _userSettings.CompanyEnabled;
            searchModel.PhoneEnabled         = _userSettings.PhoneEnabled;
            searchModel.ZipPostalCodeEnabled = _userSettings.ZipPostalCodeEnabled;

            //search registered users by default
            var registeredRole = _userService.GetUserRoleBySystemName(NopUserDefaults.RegisteredRoleName);

            if (registeredRole != null)
            {
                searchModel.SelectedUserRoleIds.Add(registeredRole.Id);
            }

            //prepare available user roles
            _aclSupportedModelFactory.PrepareModelUserRoles(searchModel);

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
Exemplo n.º 7
0
        public UserSearchModel GetSearchForm(UsersSettings settings)
        {
            var model = new UserSearchModel();

            var userData = settings.UserData;

            model.EnableBtnList = new BsSelectList <YesNoEnum?>();
            model.EnableBtnList.ItemsFromEnum(typeof(YesNoEnum));
            model.EnableBtnList.SelectedValues = YesNoEnum.All;


            model.RoleBtnList = new BsSelectList <UserRoles?>();

            if (userData.IsDoctor)
            {
                model.RoleBtnList.ItemsFromEnum(typeof(UserRoles), UserRoles.Admin);
            }
            else
            {
                model.RoleBtnList.ItemsFromEnum(typeof(UserRoles));
            }

            model.RoleBtnList.SelectedValues = UserRoles.All;

            model.GenderBtnList = new BsSelectList <GenderEnum?>();
            model.GenderBtnList.ItemsFromEnum(typeof(GenderEnum));
            model.GenderBtnList.SelectedValues = GenderEnum.Both;


            return(model);
        }
Exemplo n.º 8
0
        public ActionResult InitDataTable(UserSearchModel model)
        {
            var query = _userService.GetAllUser(model.UserName, model.Email,
                                                model.Phone, model.SelectedRoles, model.iDisplayStart / model.iDisplayLength, model.iDisplayLength);

            var filterResult = query.Select(t => new UserListModel
            {
                Id           = t.Id,
                UserName     = t.UserName,
                Email        = t.Email,
                Phone        = t.Phone,
                Active       = t.Active,
                RegisterDate = WebHelper.ConvertToUserTime(t.RegisterDate)
            });

            int sortId = model.iDisplayStart + 1;
            var result = from t in filterResult
                         select new[]
            {
                t.Id.ToString(),
                sortId++.ToString(),
                t.UserName,
                t.Email,
                t.Phone.ToString(),
                t.RegisterDate.ToString(),
                t.Active.ToString(),
                t.Id.ToString()
            };

            return(DataTableJsonResult(model.sEcho, model.iDisplayStart, query.TotalCount, query.TotalCount, result));
        }
Exemplo n.º 9
0
        public ActionResult Index(UserSearchModel search)
        {
            try
            {
                var users = _userService.GetUsers(1, _webHelper.ExcelSheetMaxRows, search.WarehouseId, (search.UserId == null) ? 0 : search.UserId.Value);
                var table = new DataTable();
                table.Columns.Add(_resourceManager.GetString("User.Name"));
                table.Columns.Add(_resourceManager.GetString("User.FullName"));
                table.Columns.Add(_resourceManager.GetString("User.Warehouse"));
                table.Columns.Add(_resourceManager.GetString("User.Role"));

                foreach (var user in users)
                {
                    table.Rows.Add(new object[]
                    {
                        user.UserName,
                        user.FullName,
                        user.Warehouse.WarehouseName,
                        user.Role.Name,
                    });
                }

                var excelData = _exportManager.ExportExcelFromDataTable(table, "Users", null);
                return(File(excelData, FileContentType.EXCEL, "Users.xlsx"));
            }
            catch (Exception ex)
            {
                ErrorNotification(_resourceManager.GetString("Error" + ex.Message));
                return(Redirect(Request.RawUrl));
            }
        }
Exemplo n.º 10
0
        public ActionResult SearchUsers(string request, string university, string faculty, string city,
                                        int?course, int?minage, int?maxage, int?minrating, int?maxrating)
        {
            List <UserModel> users = _unitOfWork.Users.SearchUsers(request, university, faculty, city,
                                                                   course, minage, maxage, minrating, maxrating);

            _searchUser = _unitOfWork.Users.UpdateUserSearch(request, university, faculty, city,
                                                             course, minage, maxage, minrating, maxrating);

            ViewBag.UserSearch = _searchUser;

            UserModel user = Session["CurrentUser"] as UserModel;

            ViewBag.CurrentUser = user;
            ViewBag.Users       = users;

            List <CityModel> cities = _unitOfWork.Cities.GetCities();

            ViewBag.Cities = cities;

            List <UniversityModel> universities = _unitOfWork.Universities.GetUniversities();

            ViewBag.Universities = universities;

            List <UniversityFacultyModel> faculties = universities.ElementAt(0).Faculties;

            ViewBag.Faculties = faculties;

            return(View("All"));
        }
Exemplo n.º 11
0
        private UserDto GetUserForDetails(int userId, bool loadManager)
        {
            var userSearchModel = new UserSearchModel {
                PageSize = int.MaxValue, SortColumn = "Name"
            };
            var user = _employeeApiClient.GetUser(userId).Result;

            if (loadManager)
            {
                var managers = _employeeApiClient.GetUsers(userSearchModel).Result.UserSearchResult.Where(x => x.Id != userId).ToList();
                user.ManagerSelectList = SelectedListHelper.GetSelectListForManager(managers, user.ManagerId?.ToString());
            }
            var linkedUserApplicationIds = user.Applications.Select(x => x.ApplicationId).ToList();
            var userGroupSearch          = new UserGroupSearchModel {
                PageSize = int.MaxValue, SortColumn = "Name"
            };

            userGroupSearch          = _employeeApiClient.GetUserGroups(userGroupSearch).Result;
            user.UserGroupSelectList = SelectedListHelper.GetSelectListForUserGroup(userGroupSearch.UserGroupSearchResult, user.UserGroupId?.ToString());

            var searchWebApplication = new WebApplicationSearchModel {
                PageSize = int.MaxValue, SortColumn = "Name", SortDirection = "Asc"
            };

            searchWebApplication          = _employeeApiClient.GetWebApplications(searchWebApplication).Result;
            user.ApplicationSelectList    = SelectedListHelper.GetApplicationTaskSelectList(searchWebApplication.WebApplicationSearchResult, linkedUserApplicationIds);
            user.LinkedUserApplicationIds = linkedUserApplicationIds.Select(x => x.ToString()).ToList();
            return(user);
        }
        public HttpResponseMessage GetNearByUser([FromBody] UserSearchModel model)
        {
            try
            {
                LogRequest(model);

                if (!ModelState.IsValid)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }

                List <SearchedUser> searchedUsers = new NeeoSearch().FindUserByName(model.UId, model.SearchText, model.Latitude, model.Longitude, model.IsCurrentLocation);

                return(Request.CreateResponse(HttpStatusCode.OK, new { SearchedUsers = searchedUsers }));
            }
            catch (ApplicationException applicationException)
            {
                return(Request.CreateErrorResponse((HttpStatusCode)Convert.ToInt16(applicationException.Message), NeeoDictionaries.HttpStatusCodeDescriptionMapper[Convert.ToInt16(applicationException.Message)]));
            }
            catch (Exception exception)
            {
                Logger.LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().GetType(), exception.Message, exception);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Exemplo n.º 13
0
        public IActionResult UsersList([FromQuery] UserSearchModel searchModel)
        {
            var negate = searchModel.RoleIds == null;

            searchModel.RoleIds = searchModel.RoleIds ?? new int[]
            {
                _roleService.FirstOrDefault(x => x.SystemName == SystemRoleNames.Visitor)?.Id ?? 0
            };
            var users = _userService.GetUsers(searchModel.SearchPhrase, searchModel.RoleIds, null, SortOrder.Ascending, searchModel.Current,
                                              searchModel.RowCount, out int totalMatches, negate);

            //convert to model
            var userModels = users.Select(x =>
            {
                var userModel   = _modelMapper.Map <UserModel>(x);
                userModel.Roles = x.Roles?.Select(y => _modelMapper.Map <RoleModel>(y)).ToList();
                return(userModel);
            }).ToList();

            var roles      = _roleService.Get(x => true);
            var roleModels = roles.Select(x => _modelMapper.Map <RoleModel>(x)).ToList();

            return(R.Success.With("users", userModels)
                   .With("roles", roleModels)
                   .WithGridResponse(totalMatches, searchModel.Current, searchModel.RowCount)
                   .Result);
        }
Exemplo n.º 14
0
        public async Task <PagedModel <SysUserDto> > SearchUsers(UserSearchModel searchModel)
        {
            Expression <Func <SysUser, bool> > whereCondition = x => x.Status > 0;

            if (!string.IsNullOrWhiteSpace(searchModel.Account))
            {
                whereCondition = whereCondition.And(x => x.Account.Contains(searchModel.Account));
            }

            if (!string.IsNullOrWhiteSpace(searchModel.Name))
            {
                whereCondition = whereCondition.And(x => x.Name.Contains(searchModel.Name));
            }

            var pagedModel = await _userRepository.PagedAsync(searchModel.PageIndex, searchModel.PageSize, whereCondition, x => x.ID);

            var result = _mapper.Map <PagedModel <SysUserDto> >(pagedModel);

            if (result.Count > 0)
            {
                var depts = await _deptRepository.SelectAsync(x => true);

                var roles = await _roleRepository.SelectAsync(x => true);

                foreach (var user in result.Data)
                {
                    user.DeptName = depts.FirstOrDefault(x => x.ID == user.DeptId)?.FullName;
                    var roleIds = string.IsNullOrWhiteSpace(user.RoleId) ? new List <long>()
                        : user.RoleId.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x));
                    user.RoleName = string.Join(',', roles.Where(x => roleIds.Contains(x.ID)).Select(x => x.Name));
                }
            }

            return(result);
        }
Exemplo n.º 15
0
        public virtual IActionResult UserList(UserSearchModel searchModel)
        {
            //prepare model
            var model = _userModelFactory.PrepareUserListModel(searchModel);

            return(Json(model));
        }
Exemplo n.º 16
0
        private string GetFilterStringForGetUsersWithTasks(UserSearchModel searchModel)
        {
            var filterString = string.Empty;

            if (searchModel != null)
            {
                if (searchModel.ApplicationId > 0)
                {
                    filterString = ODataFilterConstant.Filter + $"Applications/any(ap: ap/ApplicationId eq {searchModel.ApplicationId})";
                }
                else if (searchModel.Id > 0)
                {
                    filterString = ODataFilterConstant.Filter + $"Id eq {searchModel.Id}";
                }
                if (!string.IsNullOrWhiteSpace(searchModel.FilterText))
                {
                    if (!string.IsNullOrWhiteSpace(filterString))
                    {
                        filterString += $" and contains(Name,'{searchModel.FilterText}') eq true";
                    }
                    else
                    {
                        filterString = ODataFilterConstant.Filter + $"contains(Name,'{searchModel.FilterText}') eq true";
                    }
                }
                filterString += ODataFilterConstant.Expand + $"{ nameof(UserDto.Tasks)}($expand=Task,TaskType)";
                AddPageSizeNumberAndSortingInFilterString(searchModel, ref filterString);
            }
            return(filterString);
        }
Exemplo n.º 17
0
        public JsonResult GetUsers(UserSearchModel searchModel)
        {
            var result = new ResponseResult();

            try
            {
                var userService = new UserService();

                if (userService.SearchEnabled(LoginUser.UserId, searchModel))
                {
                    var pager = new UserService().GetUsers(searchModel);

                    // 在线用户
                    var onlienUsers = PKBag.OnlineUserRecorder.GetUserList();
                    foreach (var user in pager.Items)
                    {
                        user.IsOnline = onlienUsers.Where(u => u.UserName == user.UserName).Any();
                    }

                    result.Data = pager;
                }
                else
                {
                    result.Data = new PagerResult <User>();
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = MessageConst.System_Error;
                _logger.Info(ex);
            }

            return(Json(result));
        }
Exemplo n.º 18
0
        private void UpdateUsersGrid(UserSearchModel search = null)
        {
            dgvUsers.Rows.Clear();
            var query = _context.Users.Where(u => u.Deleted == false);

            if (search != null)
            {
                if (!string.IsNullOrEmpty(search.LastName))
                {
                    query = query.Where(u => u.LastName.Contains(search.LastName));
                }
                if (!string.IsNullOrEmpty(search.FirstName))
                {
                    query = query.Where(u => u.FirstName.Contains(search.FirstName));
                }
            }
            foreach (var item in query)
            {
                var pathTmp = Path.Combine(Directory.GetCurrentDirectory(), "images", item.Image);
                if (File.Exists(pathTmp))
                {
                    var imageBytes = File.ReadAllBytes(pathTmp);

                    using (MemoryStream ms = new MemoryStream(imageBytes))
                    {
                        dgvUsers.Rows.Add(new object[] { item.Id, item.FirstName, item.LastName, Image.FromStream(ms), item.MobilePhoneNumber,
                                                         item.DateRegistered, item.LastLoginDate, item.Email });
                    }
                }
            }
        }
Exemplo n.º 19
0
        //show ra table nhân viên
        public ActionResult List(UserSearchModel searchModel)
        {
            var pagedList = UserSevice.Search(searchModel.TenNV, searchModel.TaiKhoan, searchModel.SoDT, searchModel.ChucVu, searchModel.PageIndex);

            pagedList.SearchModel = searchModel;
            return(PartialView("_List", pagedList));
        }
Exemplo n.º 20
0
        /// <summary>
        /// Prepare user search model
        /// </summary>
        /// <param name="searchModel">User search model</param>
        /// <returns>User search model</returns>
        public virtual UserSearchModel PrepareUserSearchModel(UserSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //search registered users by default
            searchModel.SelectedUserRoleIds.Add((int)Role.User);

            //prepare available user roles
            var availableRoles = new[] { Role.User, Role.Admin };

            searchModel.AvailableUserRoles = availableRoles.Select(role => new SelectListItem
            {
                Text     = role.ToString(),
                Value    = ((int)role).ToString(),
                Selected = searchModel.SelectedUserRoleIds.Contains((int)role)
            }).ToList();

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Searches the user.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public async Task <List <UserSearchViewModel> > SearchUser(UserSearchModel model)
        {
            const string defaultSort = "Name ASC";
            var          sortType    = model.IsSortDesc ? "DESC" : "ASC";
            var          sortField   = ValidateUtils.IsNullOrEmpty(model.SortField)
                ? defaultSort
                : $"{model.SortField} {sortType}";
            var query = _userProfileRepository.GetManyAsNoTracking(x =>
                                                                   ValidateUtils.IsNullOrEmpty(model.Name) ||
                                                                   x.FirstName.ToUpper().Contains(model.Name.ToUpper()) &&
                                                                   ValidateUtils.IsNullOrEmpty(model.Name) ||
                                                                   x.LastName.ToUpper().Contains(model.Name.ToUpper()) &&
                                                                   ValidateUtils.IsNullOrEmpty(model.Phone) ||
                                                                   x.Phone.Equals(model.Name) &&
                                                                   ValidateUtils.IsNullOrEmpty(model.Email) ||
                                                                   x.Email.ToUpper().Contains(model.Email.ToUpper()))
                        .Select(x => new UserSearchViewModel
            {
                Address = x.Address,
                UserId  = x.UserProfileId,
                Email   = x.Email,
                Name    = $"{x.FirstName} {x.LastName}"
            });
            var result = query.Skip((model.Page - 1) * model.PageSize)
                         .Take(model.PageSize);

            return(result.ToList());
        }
Exemplo n.º 22
0
        public async Task <ActionResult <List <UserModel> > > Users([FromQuery] UserSearchModel model)
        {
            var users = _userManager.Users;

            if (model.Text is not null or "")
            {
                users = users.Where(u => u.Email.Contains(model.Text) ||
                                    u.UserName.Contains(model.Text));
            }

            if (model.Page > 1)
            {
                users = users.Skip((model.Page - 1) * MaxPageSize);
            }
            // pagination
            var usersList = await users
                            .OrderBy(u => u.Id)
                            .Take(MaxPageSize)
                            .ToListAsync();

            // query everything and return it
            var final = new List <UserModel>();

            foreach (var user in usersList)
            {
                final.Add(new()
                {
                    Id       = user.Id,
                    Email    = user.Email,
                    UserName = user.UserName,
                    Roles    = await _userManager.GetRolesAsync(user)
                });
            }
            return(final);
        }
Exemplo n.º 23
0
        public async Task <IActionResult> ApplicationUserGrid(UserSearchModel model)
        {
            model = InitializeUserModel(model, model.ApplicationId);
            var result = await _employeeFacadeApiClient.GetUsers(model);

            return(PartialView(result));
        }
Exemplo n.º 24
0
        public async Task <List <SelectListItem> > GetUserSelectList(List <int> listRoleId = null)
        {
            try
            {
                var userSelectList = new List <SelectListItem>();
                var model          = new UserSearchModel
                {
                    RoleIds  = listRoleId,
                    PageSize = -1
                };
                var req = new BaseRequest <UserSearchModel>(model);
                var url = _apiServer.AQIdentityAdminApi.GetCurrentServer() + _adminPortalApiUrl.IdentityAdminAPI.SearchAccounts;
                var res = await _aPIExcute.PostData <PagedListClientModel <UserViewModel>, UserSearchModel>(url, HttpMethodEnum.POST, null, req, Token);

                if (res.IsSuccessStatusCode)
                {
                    var listUser = res.ResponseData;
                    userSelectList = listUser.Data.Select(x => new SelectListItem(x.GetFullName(), x.UserId)).ToList();
                    return(userSelectList);
                }

                return(userSelectList);
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 25
0
        public JsonResult GetOnlineUsers(UserSearchModel searchModel)
        {
            var result = new ResponseResult();

            try
            {
                var skip        = (searchModel.PageIndex - 1) * searchModel.PageSize;
                var onlienUsers = searchModel.UserType > 0
                    ? PKBag.OnlineUserRecorder.GetUserList().Where(u => u.UserDegree == searchModel.UserType).OrderBy(u => u.UserName).Skip(skip).Take(searchModel.PageSize).ToList()
                    : PKBag.OnlineUserRecorder.GetUserList().OrderBy(u => u.UserName).Skip(skip).Take(searchModel.PageSize).ToList();
                //var userNames = onlienUsers.Select(u => u.UserName).ToList();
                //var users = new UserService().GetUsers(userNames);

                var pager = new PagerResult <App.Core.OnlineStat.OnlineUser>();
                pager.Items     = onlienUsers;
                pager.RowCount  = PKBag.OnlineUserRecorder.GetUserList().Count;
                pager.PageCount = pager.RowCount % searchModel.PageSize == 0 ? pager.RowCount / searchModel.PageSize : pager.RowCount / searchModel.PageSize + 1;

                result.Data = pager;
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = MessageConst.System_Error;
                _logger.Info(ex);
            }

            return(Json(result));
        }
Exemplo n.º 26
0
        public IEnumerable <UserModel> SearchUser(UserSearchModel search, out int count)
        {
            IQueryable <UserEntity> userMatched;

            if (string.IsNullOrEmpty(search.Keyword))
            {
                userMatched = dbContext.Users;
            }
            else
            {
                userMatched = dbContext.Users.Where(
                    u => u.Username.ToLower().Contains(search.Keyword.ToLower()) ||
                    u.FullName.ToLower().Contains(search.Keyword.ToLower()) ||
                    u.Phone.ToLower().Contains(search.Keyword.ToLower()) ||
                    u.Email.ToLower().Contains(search.Keyword.ToLower())
                    );
            }
            count = userMatched.Count();
            return(userMatched.OrderBy(u => u.Username)
                   .Skip((search.Page - 1) * search.RowPerPage)
                   .Take(search.RowPerPage)
                   .Select(u => new UserModel {
                Username = u.Username,
                FullName = u.FullName,
                Phone = u.Phone,
                Email = u.Email,
            }));
        }
Exemplo n.º 27
0
        public async Task <IActionResult> Search([FromQuery] string q = "")
        {
            if (q == null)
            {
                q = "";
            }
            UserSearchModel model = new UserSearchModel();

            model.SearchString = q;
            IQueryable <User> searchQuery = Db.Users;
            bool orderDescending          = true;

            foreach (string sub in q.Split(' ', StringSplitOptions.RemoveEmptyEntries))
            {
                if (sub.StartsWith("order:"))
                {
                    string order = sub.Substring("order:".Length);
                    if (Regex.IsMatch(order, ".*asc.*"))
                    {
                        orderDescending = false;
                    }
                }
                else if (sub.StartsWith("role:"))
                {
                    string role = sub.Substring("role:".Length);
                    searchQuery = searchQuery.Where(x => x.Role.Name.Contains(role, StringComparison.InvariantCultureIgnoreCase));
                }
                else if (sub.StartsWith("!role:"))
                {
                    string role = sub.Substring("!role:".Length);
                    searchQuery = searchQuery.Where(x => !x.Role.Name.Contains(role, StringComparison.InvariantCultureIgnoreCase));
                }
                else if (sub.StartsWith("!"))
                {
                    searchQuery = searchQuery.Where(x =>
                                                    !x.FullName.Contains(sub.Substring(1), StringComparison.InvariantCultureIgnoreCase) &&
                                                    !x.Username.Contains(sub.Substring(1), StringComparison.InvariantCultureIgnoreCase));
                }
                else
                {
                    searchQuery = searchQuery.Where(x =>
                                                    x.FullName.Contains(sub, StringComparison.InvariantCultureIgnoreCase) ||
                                                    x.Username.Contains(sub, StringComparison.InvariantCultureIgnoreCase));
                }
            }
            if (orderDescending)
            {
                searchQuery = searchQuery.OrderByDescending(x => x.Id);
            }
            else
            {
                searchQuery = searchQuery.OrderBy(x => x.Id);
            }

            model.FoundUsers = await searchQuery
                               .ToArrayAsync();

            return(View(model));
        }
Exemplo n.º 28
0
        public void UpdateUsersGrid(UserSearchModel search = null)
        {
            dataGridViewUsers.Rows.Clear();
            var query = context.Users.Where(u => u.Deleted == false);

            if (search != null)
            {
                if (!string.IsNullOrEmpty(search.LastName))
                {
                    query = query.Where(u => u.LastName.Contains(search.LastName));
                }
                if (!string.IsNullOrEmpty(search.FirstName))
                {
                    query = query.Where(u => u.FirstName.Contains(search.FirstName));
                }
            }

            foreach (var item in query)
            {
                try
                {
                    //if (!item.Deleted)
                    //{
                    //var pathTmp = Path.Combine(Directory.GetCurrentDirectory(), "user_images", item.UserImage);
                    if (item.ToString() != "")
                    {
                        DataGridViewColumn column = dataGridViewUsers.Columns[8];
                        column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                        ((DataGridViewImageColumn)dataGridViewUsers.Columns[8]).ImageLayout = DataGridViewImageCellLayout.Stretch;
                        int k = 0;

                        using (MemoryStream ms = new MemoryStream(item.UserImage))
                        {
                            try
                            {
                                dataGridViewUsers.Rows.Add(new object[] { item.Id, item.FirstName, item.LastName, item.MobilePhoneNumber,
                                                                          item.DateRegistered, item.LastLoginDate, item.Deleted, item.Email, Image.FromStream(ms) });
                                dataGridViewUsers.Rows[k++].Height = 50;
                                dataGridViewUsers.Rows[k].Height   = 50;
                            }
                            catch (Exception)
                            {
                                dataGridViewUsers.Rows.Add(new object[] { item.Id, item.FirstName, item.LastName, item.MobilePhoneNumber,
                                                                          item.DateRegistered, item.LastLoginDate, item.Email, item.Deleted });
                                dataGridViewUsers.Rows[k++].Height = 50;
                            }
                        }
                    }
                    else
                    {
                        dataGridViewUsers.Rows.Add(new object[] { item.Id, item.FirstName, item.LastName, item.MobilePhoneNumber,
                                                                  item.DateRegistered, item.LastLoginDate, item.Email, item.Deleted });
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// Get user by filter
 /// </summary>
 /// <param name="searchModel"></param>
 /// <returns></returns>
 public List <Vw_Core_User> SearchUser(UserSearchModel searchModel)
 {
     using (var db = _connectionFactory.Open())
     {
         //Filter user by customer type
         return(db.Select <Vw_Core_User>().Where(u => (searchModel.Status == -1 || u.Status == searchModel.Status)).ToList());
     }
 }
Exemplo n.º 30
0
        public ActionResult Users(UserSearchModel model, string orderBy, int page = 1)
        {
            var users         = _userService.SearchUsers(model);
            var sortedUsers   = GetSortedUsers(users, orderBy);
            var userViewModel = CreateUserViewModel(sortedUsers, page);

            return(View(userViewModel));
        }
Exemplo n.º 31
0
 public ActionResult ManagerLookup()
 {
     var userSearchModel = new UserSearchModel();
     return PartialView("ManagerLookup", userSearchModel);
 }
Exemplo n.º 32
0
        public IEnumerable<UserViewModel> SearchUsers(UserSearchModel searchModel, string userId)
        {
            var usersDb = _userRepository.GetUsers(userId).ToList();
            var userList = ModelConverters.ToUserViewModelList(usersDb);
            var result = new List<UserViewModel>();

            if (string.IsNullOrEmpty(searchModel.Country) == false)
            {
                result.AddRange(userList.Where(m => m.Country != null && m.Country.ToLower().Contains(searchModel.Country.ToLower())));
            }

            if (string.IsNullOrEmpty(searchModel.City) == false)
            {
                result.AddRange(userList.Where(m => m.City != null && m.City.ToLower().Contains(searchModel.City.ToLower())));
            }

            if (string.IsNullOrEmpty(searchModel.Genres) == false)
            {
                result.AddRange(userList.Where(m => m.BestGenres != null && m.BestGenres.ToLower().Contains(searchModel.Genres.ToLower())));
            }

            if (string.IsNullOrEmpty(searchModel.Atrists) == false)
            {
                result.AddRange(
                    userList.Where(m =>
                        m.BestVocalist != null && m.BestVocalist.ToLower().Contains(searchModel.Atrists.ToLower()) ||
                         m.BestForeignArtist != null && m.BestForeignArtist.ToLower().Contains(searchModel.Atrists.ToLower()) ||
                         m.BestNativeArtist != null && m.BestNativeArtist.ToLower().Contains(searchModel.Atrists.ToLower()))
                         );
            }

            if (string.IsNullOrEmpty(searchModel.FirstName) == false)
            {
                result.AddRange(userList.Where(m => m.FirstName != null && m.FirstName.ToLower().Contains(searchModel.FirstName.ToLower())));
            }

            if (string.IsNullOrEmpty(searchModel.LastName) == false)
            {
                result.AddRange(userList.Where(m => m.LastName != null && m.LastName.ToLower().Contains(searchModel.LastName.ToLower())));
            }

            if (searchModel.BirthDate.HasValue)
            {
                result.AddRange(userList.Where(m => m.BirthDate.Date == searchModel.BirthDate.Value.Date));
            }

            return result;
        }
Exemplo n.º 33
0
 public IActionResult Search(UserSearchModel model)
 {
     return Json(_userDomain.GetAll().ToPaginated(model));
 }
Exemplo n.º 34
0
 public ActionResult Search(UserSearchModel model)
 {
     model.Search();
     return View(model);
 }
Exemplo n.º 35
0
 public ActionResult ManagerLookup(UserSearchModel userSearchModel)
 {
     userSearchModel.Search();
     return PartialView("ManagerLookup", userSearchModel);
 }
Exemplo n.º 36
0
 public ActionResult Search()
 {
     var model = new UserSearchModel();
     return View(model);
 }
Exemplo n.º 37
0
//        public ActionResult UserLookup()
//        {
//            var userSearchModel = new UserSearchModel();
//            return PartialView("UserLookup", userSearchModel);
//        }

        public ActionResult UserLookup(string idName, string valueName)
        {
            var userSearchModel = new UserSearchModel
            {
                LookupInputId = idName,
                LookupInputIdValue = valueName
            };
            return PartialView("UserLookup", userSearchModel);
        }