public HttpResponseMessage Search([FromUri] ContactRequestSearchRequest model) { int rows = 0; List <ContactRequest> contactRequests = ContactRequestService.Search(model, out rows); SearchResponse <ContactRequest> response = new SearchResponse <ContactRequest>(); response.Items = contactRequests; response.ResultCount = rows; return(Request.CreateResponse(HttpStatusCode.OK, response)); }
// SEARCH public static List <ContactRequest> Search(ContactRequestSearchRequest model, out int totalRows) { List <ContactRequest> list = null; int r = 0; DataProvider.ExecuteCmd(GetConnection, "dbo.ContactRequest_Search" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@SearchStr", model.SearchString); paramCollection.AddWithValue("@CurrentPage", model.CurrentPage); paramCollection.AddWithValue("@ItemsPerPage", model.ItemsPerPage); } , map : delegate(IDataReader reader, short set) { switch (set) { case 0: //first result set ContactRequest p = new ContactRequest(); int startingIndex = 0; //startingOrdinal p.Id = reader.GetInt32(startingIndex++); p.Name = reader.GetSafeString(startingIndex++); //extension method p.Email = reader.GetSafeString(startingIndex++); p.Message = reader.GetSafeString(startingIndex++); p.Notes = reader.GetSafeString(startingIndex++); r = reader.GetSafeInt32(startingIndex++); if (list == null) { list = new List <ContactRequest>(); } list.Add(p); break; } } ); totalRows = r; return(list); }