public List <OtherCharge> GetAllOtherCharge(OtherChargeAdvanceSearch otherChargeAdvanceSearch) { List <OtherCharge> otherChargeList = 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].[GetAllOtherCharge]"; cmd.Parameters.Add("@SearchValue", SqlDbType.NVarChar, -1).Value = string.IsNullOrEmpty(otherChargeAdvanceSearch.SearchTerm) ? "" : otherChargeAdvanceSearch.SearchTerm.Trim(); cmd.Parameters.Add("@RowStart", SqlDbType.Int).Value = otherChargeAdvanceSearch.DataTablePaging.Start; if (otherChargeAdvanceSearch.DataTablePaging.Length == -1) { cmd.Parameters.AddWithValue("@Length", DBNull.Value); } else { cmd.Parameters.Add("@Length", SqlDbType.Int).Value = otherChargeAdvanceSearch.DataTablePaging.Length; } cmd.CommandType = CommandType.StoredProcedure; using (SqlDataReader sdr = cmd.ExecuteReader()) { if ((sdr != null) && (sdr.HasRows)) { otherChargeList = new List <OtherCharge>(); while (sdr.Read()) { OtherCharge otherCharge = new OtherCharge(); { otherCharge.Code = (sdr["Code"].ToString() != "" ? int.Parse(sdr["Code"].ToString()) : otherCharge.Code); otherCharge.Description = (sdr["Description"].ToString() != "" ? sdr["Description"].ToString() : otherCharge.Description); otherCharge.SACCode = (sdr["SACCode"].ToString() != "" ? sdr["SACCode"].ToString() : otherCharge.SACCode); otherCharge.TotalCount = (sdr["TotalCount"].ToString() != "" ? int.Parse(sdr["TotalCount"].ToString()) : otherCharge.TotalCount); otherCharge.FilteredCount = (sdr["FilteredCount"].ToString() != "" ? int.Parse(sdr["FilteredCount"].ToString()) : otherCharge.FilteredCount); } otherChargeList.Add(otherCharge); } } } } } } catch (Exception ex) { throw ex; } return(otherChargeList); }
public List <OtherCharge> GetAllOtherCharge(OtherChargeAdvanceSearch otherChargeAdvanceSearch) { return(_otherChargeRepository.GetAllOtherCharge(otherChargeAdvanceSearch)); }