public void Search(int?key, SearchProfileCriteriaModel model) { var data = Mapper.Map <SearchProfileCriteria>(model); var pageIndex = (key ?? 1); var searchResult = _searchService.SearchProfiles(data, pageIndex, PageSize); var list = new List <ApiProfileInfo>(searchResult.Profiles.Count()); list.AddRange(searchResult.Profiles.Select(profile => new ApiProfileInfo { Id = profile.Id, Guid = profile.Guid, Name = profile.Name, Email = profile.User.Email, UserName = profile.User.UserName, ProfilePhotoGuid = profile.ProfilePhotoGuid, Country = profile.Location.CountryName, Age = DateTime.Now.Year - profile.BirthYear })); var result = new ApiSearchResult { PageIndex = pageIndex, PageSize = PageSize, Profiles = list, Total = searchResult.Total }; Response.ContentType = "application/json"; Response.Write(JsonConvert.SerializeObject(result)); }
private ActionResult SearchProfile(int?key, SearchProfileCriteriaModel model) { var data = Mapper.Map <SearchProfileCriteria>(model); var pageIndex = (key ?? 1); var searchResult = _searchService.SearchProfiles(data, pageIndex, PageSize); if (searchResult.Total > -1) { var profiles = searchResult.Profiles; var profilesModel = Mapper.Map <IList <ProfileModel> >(profiles); var profilesAsIPagedList = new StaticPagedList <ProfileModel>(profilesModel, pageIndex, PageSize, searchResult.Total); var searchResultModel = new SearchProfileResultModel { FacetValues = searchResult.FacetValues, SearchCriteria = Mapper.Map <SearchProfileCriteriaModel>(searchResult.SearchCriteria), Total = searchResult.Total, Profiles = profilesAsIPagedList }; ViewBag.KatushaSearchResult = searchResultModel; return(View("Search", searchResultModel)); } return(View("Search", new SearchProfileResultModel { SearchCriteria = model })); }
public ActionResult Girls(int?key, SearchProfileCriteriaModel model) { model.Gender = Sex.Female; return(SearchProfile(key, model)); }