public Seriousness Get(int id, string lang) { _seriousness = dbConnection.GetSeriousnessById(id, lang); return(_seriousness); }
public Seriousness GetSeriousnessById(int id, string lang) { var seriousness = new Seriousness(); string commandText = "SELECT DISTINCT SERIOUSNESS_LX_ID, SERIOUSNESS_CODE, "; if (lang.Equals("fr")) { commandText += " FR_DESC as SERIOUSNESS"; } else { commandText += " EN_DESC as SERIOUSNESS"; } commandText += " FROM CVPONL_OWNER.SERIOUSNESS_LX WHERE SERIOUSNESS_LX_ID = " + id; using ( OracleConnection con = new OracleConnection(DpdDBConnection)) { OracleCommand cmd = new OracleCommand(commandText, con); try { con.Open(); using (OracleDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { while (dr.Read()) { var item = new Seriousness(); item.seriousness_id = dr["SERIOUSNESS_LX_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["SERIOUSNESS_LX_ID"]); item.seriousness_code = dr["SERIOUSNESS_CODE"] == DBNull.Value ? string.Empty : dr["SERIOUSNESS_CODE"].ToString().Trim(); item.seriousness = dr["SERIOUSNESS"] == DBNull.Value ? string.Empty : dr["SERIOUSNESS"].ToString().Trim(); seriousness = item; } } } } catch (Exception ex) { string errorMessages = string.Format("DbConnection.cs - GetSeriousnessById()"); ExceptionHelper.LogException(ex, errorMessages); Console.WriteLine(errorMessages); } finally { if (con.State == ConnectionState.Open) con.Close(); } } return seriousness; }
public Seriousness Get(int id, string lang) { _seriousness = dbConnection.GetSeriousnessById(id, lang); return _seriousness; }