コード例 #1
0
ファイル: DBConnection.cs プロジェクト: hres/api-lnhpd
        public ProductRiskText GetProductRiskTextById(int id, string lang)
        {
            var riskText = new ProductRiskText();
            string commandText = "SELECT TEXT_ID, RISK_ID, ";
            if (lang.Equals("fr"))
            {
                commandText += "RISK_TEXT_F as RISK_TEXT_E ";
            }
            else {
                commandText += "RISK_TEXT_E ";
            }
            commandText += "FROM NHPPLQ_OWNER.PRODUCT_RISK_TEXT_ONLINE WHERE TEXT_ID = " + id;


            using (

                OracleConnection con = new OracleConnection(LnhpdDBConnection))
            {
                OracleCommand cmd = new OracleCommand(commandText, con);
                try
                {
                    con.Open();
                    using (OracleDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                var item = new ProductRiskText();

                                item.text_id = dr["TEXT_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["TEXT_ID"]);
                                item.risk_id = dr["RISK_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["RISK_ID"]);
                                item.risk_text = dr["RISK_TEXT_E"] == DBNull.Value ? string.Empty : dr["RISK_TEXT_E"].ToString().Trim();

                                riskText = item;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    string errorMessages = string.Format("DbConnection.cs - GetProductRiskTextById()");
                    ExceptionHelper.LogException(ex, errorMessages);
                }
                finally
                {
                    if (con.State == ConnectionState.Open)
                        con.Close();
                }
            }
            return riskText;
        }
コード例 #2
0
 public ProductRiskText Get(int id, string lang)
 {
     _riskText = dbConnection.GetProductRiskTextById(id, lang);
     return _riskText;
 }
コード例 #3
0
 public ProductRiskText Get(int id, string lang)
 {
     _riskText = dbConnection.GetProductRiskTextById(id, lang);
     return(_riskText);
 }