public List <Plant> GetAllPlant(PlantAdvanceSearch plantAdvanceSearch) { List <Plant> plantList = null; try { using (SqlConnection con = _databaseFactory.GetDBConnection()) { using (SqlCommand cmd = new SqlCommand()) { if (con.State == ConnectionState.Closed) { con.Open(); } cmd.Connection = con; cmd.CommandText = "[PSA].[GetAllPlant]"; cmd.Parameters.Add("@SearchValue", SqlDbType.NVarChar, -1).Value = string.IsNullOrEmpty(plantAdvanceSearch.SearchTerm) ? "" : plantAdvanceSearch.SearchTerm.Trim(); cmd.Parameters.Add("@RowStart", SqlDbType.Int).Value = plantAdvanceSearch.DataTablePaging.Start; if (plantAdvanceSearch.DataTablePaging.Length == -1) { cmd.Parameters.AddWithValue("@Length", DBNull.Value); } else { cmd.Parameters.Add("@Length", SqlDbType.Int).Value = plantAdvanceSearch.DataTablePaging.Length; } cmd.CommandType = CommandType.StoredProcedure; using (SqlDataReader sdr = cmd.ExecuteReader()) { if ((sdr != null) && (sdr.HasRows)) { plantList = new List <Plant>(); while (sdr.Read()) { Plant plant = new Plant(); { plant.Code = (sdr["Code"].ToString() != "" ? int.Parse(sdr["Code"].ToString()) : plant.Code); plant.Description = (sdr["Description"].ToString() != "" ? sdr["Description"].ToString() : plant.Description); plant.TotalCount = (sdr["TotalCount"].ToString() != "" ? int.Parse(sdr["TotalCount"].ToString()) : plant.TotalCount); plant.FilteredCount = (sdr["FilteredCount"].ToString() != "" ? int.Parse(sdr["FilteredCount"].ToString()) : plant.FilteredCount); } plantList.Add(plant); } } } } } } catch (Exception ex) { throw ex; } return(plantList); }
public List <Plant> GetAllPlant(PlantAdvanceSearch plantAdvanceSearch) { return(_plantRepository.GetAllPlant(plantAdvanceSearch)); }