document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public bool IsInStore(Vehicle vehicle)
  2. {
  3.     bool isInStore = false;
  4.     logger.Debug($"IsInStore invocation {vehicle.Plates.Number}");
  5.     DbConnection connection = null;
  6.  
  7.     try
  8.     {
  9.         Database db = new SqlDatabase(Configuration.ConnectionString);
  10.  
  11.         SqlConnection con = new SqlConnection(Configuration.ConnectionString);
  12.         con.Open();
  13.  
  14.         SqlCommand cmd = new SqlCommand("dbo.fn_CzyTablicaWMagazynie", con);
  15.         cmd.CommandType = CommandType.StoredProcedure;
  16.         cmd.Parameters.Add("number", SqlDbType.Char);
  17.         cmd.Parameters["number"].Value = pojazdDane.TablicaRejestracyjna.NrTabRej;
  18.         cmd.Parameters.Add("retVal", SqlDbType.Int);
  19.         cmd.Parameters["retVal"].Direction = ParameterDirection.ReturnValue;
  20.  
  21.         cmd.ExecuteScalar();
  22.         isInStore = (bool) cmd.Parameters["retVal"].Value;
  23.     }
  24.     catch (SqlException ex)
  25.     {
  26.         throw new MyException("Ther was an exception in IsInStore", ex);
  27.     }
  28.     finally
  29.     {
  30.         connection?.Dispose();
  31.     }
  32.  
  33.     return isInStore;
  34. }
');