Esempio n. 1
0
 private PagedMemberListViewModel CreatePagedListOfMembers(IEnumerable<Member> memberList, MemberSearchViewModel viewModel)
 {
     return new PagedMemberListViewModel(memberList.ToPagedList(viewModel.Page ?? 1, DefaultPageSize),
                                         page => Url.Action("Index", new RouteValueDictionary
                                                                         {
                                                                             {"Page", page},
                                                                             {"Name", viewModel.Name},
                                                                             {"PostCode", viewModel.PostCode},
                                                                             {"Reference", viewModel.Reference}
                                                                         }));
 }
Esempio n. 2
0
        public ActionResult Search(MemberSearchViewModel model)
        {
            if (string.IsNullOrEmpty(model.SearchButton) && !model.Page.HasValue)
            {
                model.Results = CreatePagedListOfMembers(this.memberService.All(), model);
                return View(model);
            }

            var searchResults = this.memberService.Search(model.Name, model.PostCode, model.Reference);
            model.Results = CreatePagedListOfMembers(searchResults, model);

            return View(model);
        }