コード例 #1
0
 public IngredientSubmission Get(int id, string lang)
 {
     _submission = dbConnection.GetIngredientSubmissionById(id, lang);
     return _submission;
 }
コード例 #2
0
 public IngredientSubmission Get(int id, string lang)
 {
     _submission = dbConnection.GetIngredientSubmissionById(id, lang);
     return(_submission);
 }
コード例 #3
0
ファイル: DBConnection.cs プロジェクト: hres/api-lnhpd
        public IngredientSubmission GetIngredientSubmissionById(int id, string lang)
        {
            var submission = new IngredientSubmission();
            string commandText = "SELECT MATRIX_ID, SUBMISSION_ID, INGREDIENT_TYPE_CODE, ";
            if (lang.Equals("fr"))
            {
                commandText += "NAME_UPPER_F as NAME_UPPER ";
            }
            else {
                commandText += "NAME_UPPER ";
            }
            commandText += "FROM NHPPLQ_OWNER.INGREDIENT_SUBMISSION_ONLINE WHERE SUBMISSION_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 IngredientSubmission();

                                item.matrix_id = dr["MATRIX_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["MATRIX_ID"]);
                                item.submission_id = dr["SUBMISSION_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["SUBMISSION_ID"]);
                                item.ingredient_type_code = dr["INGREDIENT_TYPE_CODE"] == DBNull.Value ? 0 : Convert.ToInt32(dr["INGREDIENT_TYPE_CODE"]);
                                item.brand_name = dr["NAME_UPPER"] == DBNull.Value ? string.Empty : dr["NAME_UPPER"].ToString().Trim();

                                submission = item;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    string errorMessages = string.Format("DbConnection.cs - GetIngredientSubmissionById()");
                    ExceptionHelper.LogException(ex, errorMessages);
                }
                finally
                {
                    if (con.State == ConnectionState.Open)
                        con.Close();
                }
            }
            return submission;
        }