Exemplo n.º 1
0
 public ActiveIngredient Get(int id, string lang)
 {
     _activeIngredient = dbConnection.GetActiveIngredientById(id, lang);
     return _activeIngredient;
 }
Exemplo n.º 2
0
 public ActiveIngredient GetActiveIngredientById(int id, string lang)
 {
     var activeIngredient = new ActiveIngredient();
     string commandText = "SELECT * FROM DPD_ONLINE_OWNER.WQRY_ACTIVE_INGREDIENTS WHERE 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 ActiveIngredient();
                         if (lang.Equals("fr"))
                         {
                             item.ingredient_name = dr["INGREDIENT_F"] == DBNull.Value ? string.Empty : dr["INGREDIENT_F"].ToString().Trim();
                             item.strength_unit = dr["STRENGTH_UNIT_F"] == DBNull.Value ? string.Empty : dr["STRENGTH_UNIT_F"].ToString().Trim();
                             item.dosage_unit = dr["DOSAGE_UNIT_F"] == DBNull.Value ? string.Empty : dr["DOSAGE_UNIT_F"].ToString().Trim();
                         }
                         else {
                             item.ingredient_name = dr["INGREDIENT"] == DBNull.Value ? string.Empty : dr["INGREDIENT"].ToString().Trim();
                             item.strength_unit = dr["STRENGTH_UNIT"] == DBNull.Value ? string.Empty : dr["STRENGTH_UNIT"].ToString().Trim();
                             item.dosage_unit = dr["DOSAGE_UNIT"] == DBNull.Value ? string.Empty : dr["DOSAGE_UNIT"].ToString().Trim();
                         }
                         item.active_ingredient_id = dr["ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["ID"]);
                         item.drug_code = dr["DRUG_CODE"] == DBNull.Value ? 0 : Convert.ToInt32(dr["DRUG_CODE"]);
                         item.active_ingredient_code = dr["ACTIVE_INGREDIENT_CODE"] == DBNull.Value ? 0 : Convert.ToInt32(dr["ACTIVE_INGREDIENT_CODE"]);
                         item.strength = dr["STRENGTH"] == DBNull.Value ? string.Empty : dr["STRENGTH"].ToString().Trim();
                         item.dosage_value = dr["DOSAGE_VALUE"] == DBNull.Value ? string.Empty : dr["DOSAGE_VALUE"].ToString().Trim();
                         activeIngredient = item;
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             string errorMessages = string.Format("DbConnection.cs - GetActiveIngredientById()");
             ExceptionHelper.LogException(ex, errorMessages);
         }
         finally
         {
             if (con.State == ConnectionState.Open)
                 con.Close();
         }
     }
     return activeIngredient;
 }