Example #1
0
        public IngredientSource GetIngredientSourceById(int id, string lang)
        {
            var source = new IngredientSource();
            string commandText = "SELECT MATERIAL_ID, MATRIX_ID, ";
            if (lang.Equals("fr"))
            {
                commandText += "MATERIAL_TYPE_DESC_F as MATERIAL_TYPE_DESC ";
            }
            else {
                commandText += "MATERIAL_TYPE_DESC ";
            }
            commandText += "FROM NHPPLQ_OWNER.INGREDIENT_SOURCE_ONLINE WHERE MATERIAL_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 IngredientSource();

                                item.material_id = dr["MATERIAL_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["MATERIAL_ID"]);
                                item.matrix_id = dr["MATRIX_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["MATRIX_ID"]);
                                item.material_type_desc = dr["MATERIAL_TYPE_DESC"] == DBNull.Value ? string.Empty : dr["MATERIAL_TYPE_DESC"].ToString().Trim();

                                source = item;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    string errorMessages = string.Format("DbConnection.cs - GetIngredientSourceById()");
                    ExceptionHelper.LogException(ex, errorMessages);
                }
                finally
                {
                    if (con.State == ConnectionState.Open)
                        con.Close();
                }
            }
            return source;
        }
 public IngredientSource Get(int id, string lang)
 {
     _source = dbConnection.GetIngredientSourceById(id, lang);
     return _source;
 }
 public IngredientSource Get(int id, string lang)
 {
     _source = dbConnection.GetIngredientSourceById(id, lang);
     return(_source);
 }