title: Best practices for writing multiple if else conditions using asp.net c#
body: <p>I am new to programming. I want to write multiple if else conditions using best practices. Here is my code.</p>
  
  <pre><code>public class HomeController : Controller
      {
          //Creating object of Result class
          Result result = new Result();
  
          // GET: Home
          public async Task&lt;ActionResult&gt; Index(string key, string value)
          {
              DBConnection dbConnection = new DBConnection();
              dbConnection.MakeConnection();
              try
              {
                  dbConnection.oracleCommand.CommandText = "QUERY";
                  OracleDataReader Reader = dbConnection.oracleCommand.ExecuteReader();
                  Reader.Read();
                  count = Reader.GetInt16(0);
  
                  for (int i = 0; i &lt; count; i++)
                  {
                      //Updating records
                      dbConnection.oracleCommand.CommandText = "QUERY";
                      dbConnection.oracleCommand.ExecuteNonQuery();
  
                      dbConnection.oracleCommand.CommandText = "QUERY";
                      OracleDataReader Reader2 = dbConnection.oracleCommand.ExecuteReader();
  
                      while (Reader2.Read())
                      {
                          //Getting keyname and keyvalue
                          keyName = (Reader2.GetValue(1)).ToString();
                          keyValue = (Reader2.GetValue(2)).ToString();
                      }
  
                      dbConnection.oracleCommand.CommandText = "QUERY";
                      OracleDataReader Reader3 = dbConnection.oracleCommand.ExecuteReader();
                      while (Reader3.Read())
                      {
                          if ((!Reader3.GetValue(1).Equals(System.DBNull.Value)))
                          {
                              //Checking api type
                              if ((Reader3.GetValue(1).ToString() == ("REST")))
                              {
                                  dbConnection.oracleCommand.CommandText = "QUERY";
                                  OracleDataReader Reader4 = dbConnection.oracleCommand.ExecuteReader();
  
                                  while (Reader4.Read())
                                  {
  
                                      if ((!Reader4.GetValue(0).Equals(System.DBNull.Value)))
                                      {
                                          //Getting url
                                          url = Reader4.GetValue(1).ToString();
                                          //Checking whether a get or a post
                                          if ((Reader4.GetValue(0).ToString() == ("GET")))
                                          {
                                              RestCall restCall = new RestCall();
                                              await restCall.RunAsync(keyName, keyValue);
  
                                          }
                                      }
                                      else if ((Reader4.GetValue(0).ToString() == ("POST")))
                                      {
                                          //"Do a rest call for post method.";
                                          RestCall restCall = new RestCall();
                                          await restCall.RunAsync(keyName, keyValue);
                                      }
                                      else
                                      {
                                          //"Not a get or a post";
                                          errorMessage = "Error";
                                      }
                                  }
                              }
                          }
                          else
                          {
                              //"A null value.";
                              errorMessageNull = "A null value.";
                          }
                      }
  
                      //Soap
                      if ((!Reader3.GetValue(1).Equals(System.DBNull.Value)))
                      {
                          if ((Reader3.GetValue(1).ToString() == ("SOAP")))
                          {
                              dbConnection.oracleCommand.CommandText = "QUERY";
                              OracleDataReader Reader4 = dbConnection.oracleCommand.ExecuteReader();
                              while (Reader4.Read())
                              {
  
                                  if ((!Reader4.GetValue(0).Equals(System.DBNull.Value)))
                                  {
                                      //Getting url
                                      url = Reader4.GetValue(1).ToString();
                                      //Read function
                                      if ((Reader4.GetValue(0).ToString() == ("READ")))
                                      {
                                          //SoapCall soapCall = new SoapCall();
                                          //soapCall.DoSoapCall();
                                      }
                                  }
                                  //Create function
                                  else if ((Reader4.GetValue(0).ToString() == ("CREATE")))
                                  {
                                      //"Do a soap call for post method.";
                                  }
                                  else
                                  {
                                      //"Not a get or a post";
                                      errorMessage = "Error";
                                  }
                              }
  
                          }
                          else
                          {
                              //"Not a get or a post";
                              errorMessage = "Error";
                          }
  
                      }
                      else
                      {
                          //"Not a get or a post";
                          errorMessage = "Error";
                      }
                      Reader.Dispose();
                      Reader3.Dispose();
                      dbConnection.CloseConnection();
                  }
              }
              catch (Exception e)
              {
                  exception = e.Message.ToString();
              }
  </code></pre>
  
  <p>I want to execute these queries if they meet certain conditions. After that I want to do rest and soap calls. Is there any method to write this code without using multiple if else conditions. I mean a more readable way.</p>