public override DTO.SearchFormData GetDataWithFilter(Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification) { DTO.SearchFormData searchFormData = new DTO.SearchFormData(); notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; totalRows = 0; try { string forwarderNM = null; string validFrom = null; string validTo = null; string description = null; string updatedDate = null; string updatorName = null; int? forwarderID = null; if (filters.ContainsKey("forwarderNM") && !string.IsNullOrEmpty(filters["forwarderNM"].ToString())) { forwarderNM = filters["forwarderNM"].ToString().Replace("'", "''"); } if (filters.ContainsKey("validFrom") && !string.IsNullOrEmpty(filters["validFrom"].ToString())) { validFrom = filters["validFrom"].ToString().Replace("'", "''"); } if (filters.ContainsKey("validTo") && !string.IsNullOrEmpty(filters["validTo"].ToString())) { validTo = filters["validTo"].ToString().Replace("'", "''"); } if (filters.ContainsKey("description") && !string.IsNullOrEmpty(filters["description"].ToString())) { description = filters["description"].ToString().Replace("'", "''"); } if (filters.ContainsKey("updatorName") && !string.IsNullOrEmpty(filters["updatorName"].ToString())) { updatorName = filters["updatorName"].ToString().Replace("'", "''"); } if (filters.ContainsKey("updatedDate") && !string.IsNullOrEmpty(filters["updatedDate"].ToString())) { updatedDate = filters["updatedDate"].ToString().Replace("'", "''"); } if (filters.ContainsKey("forwarderID") && filters["forwarderID"] != null) { forwarderID = Convert.ToInt32(filters["forwarderID"]); } using (TransportOfferEntities context = CreateContext()) { totalRows = context.TransportOfferMng_function_SearchTransportOffer(orderBy, orderDirection, forwarderID, forwarderNM, validFrom, validTo, description, updatedDate, updatorName).Count(); var result = context.TransportOfferMng_function_SearchTransportOffer(orderBy, orderDirection, forwarderID, forwarderNM, validFrom, validTo, description, updatedDate, updatorName); searchFormData.Data = converter.DB2DTO_TransportOfferSearch(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList()); } searchFormData.Forwarders = supportFactory.GetForwarder(); return(searchFormData); } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; notification.DetailMessage.Add(ex.Message); if (ex.GetBaseException() != null) { notification.DetailMessage.Add(ex.GetBaseException().Message); } return(searchFormData); } }