public virtual async Task <ActionResult> SearchAsync(int?p, string search, CancellationToken cancellationToken = default(CancellationToken))
        {
            var pageIndex = p ?? 1;
            var allUsers  = string.IsNullOrWhiteSpace(search)
                ? await MembershipService.GetAllAsync(pageIndex, ForumConfiguration.Instance.AdminListPageSize, cancellationToken)
                : await MembershipService.SearchMembers(search, pageIndex,
                                                        ForumConfiguration.Instance.AdminListPageSize);

            // Redisplay list of users
            var allViewModelUsers = allUsers.Select(user => new PublicSingleMemberListViewModel
            {
                UserName    = user.UserName,
                NiceUrl     = user.NiceUrl,
                CreateDate  = user.CreatedAtUTC,
                TotalPoints = user.TotalPoints
            }).ToList();

            var memberListModel = new PublicMemberListViewModel
            {
                Users      = allViewModelUsers,
                PageIndex  = pageIndex,
                TotalCount = allUsers.TotalCount,
                Search     = search
            };

            return(View(memberListModel));
        }
Beispiel #2
0
        public ActionResult Search(int? p, string search)
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                var pageIndex = p ?? 1;
                var allUsers = string.IsNullOrEmpty(search) ? MembershipService.GetAll(pageIndex, SiteConstants.Instance.AdminListPageSize) :
                                    MembershipService.SearchMembers(search, pageIndex, SiteConstants.Instance.AdminListPageSize);

                // Redisplay list of users
                var allViewModelUsers = allUsers.Select(user => new PublicSingleMemberListViewModel
                                                                    {
                                                                        UserName = user.UserName,
                                                                        NiceUrl = user.NiceUrl,
                                                                        CreateDate = user.CreateDate,
                                                                        TotalPoints = user.TotalPoints,
                                                                    }).ToList();

                var memberListModel = new PublicMemberListViewModel
                {
                    Users = allViewModelUsers,
                    PageIndex = pageIndex,
                    TotalCount = allUsers.TotalCount,
                    Search = search
                };

                return View(memberListModel);
            }
        }