public IHttpActionResult Search([ModelBinder(typeof(SearchCriteriaBinder))] webModel.SearchCriteria criteria) { var result = _contactSearchService.Search(criteria.ToCoreModel()); var retVal = new webModel.SearchResult(); var start = criteria.Start; var count = criteria.Count; // all organizations var organizations = result.Organizations.Select(x => x.ToWebModel()); var contacts = result.Contacts.Select(x => x.ToWebModel()); retVal.TotalCount = organizations.Count() + result.TotalCount; retVal.Members.AddRange(organizations.Skip(start).Take(count)); count -= organizations.Count(); retVal.Members.AddRange(contacts.Take(count)); return Ok(retVal); }
public IHttpActionResult Search([ModelBinder(typeof(SearchCriteriaBinder))] webModel.SearchCriteria criteria) { var result = _contactSearchService.Search(criteria.ToCoreModel()); var retVal = new webModel.SearchResult(); var start = criteria.Start; var count = criteria.Count; // all organizations var organizations = result.Organizations.Select(x => x.ToWebModel()); var contacts = result.Contacts.Select(x => x.ToWebModel()); retVal.TotalCount = organizations.Count() + result.TotalCount; retVal.Members.AddRange(organizations.Skip(start).Take(count)); count -= organizations.Count(); retVal.Members.AddRange(contacts.Take(count)); return(Ok(retVal)); }