document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. [Secured("AddMovieToStore")]
  2. public void AddMovieToStore(Guid movieId, int quantity)
  3. {
  4.    DbProviderFactory providerFactory = DbProviderFactories.
  5.      GetFactory(ConfigurationManager.
  6.      ConnectionStrings["MoviesDB"].ProviderName);
  7.    using (DbConnection conn = providerFactory.CreateConnection())
  8.    {
  9.       conn.ConnectionString = ConfigurationManager.
  10.          ConnectionStrings["MoviesDB"].ConnectionString.ToString();
  11.       DbCommand command = conn.CreateCommand();
  12.       command.CommandText = "INSERT INTO MoviesToStore  " +
  13.           "(movieId, storeId, quantity) Values (@movieId, @storeId, @quantity)";
  14.       DbParameter mIdParam = command.CreateParameter();
  15.       mIdParam.ParameterName = "@movieId";
  16.       mIdParam.Value = movieId;
  17.       DbParameter sIdParam = command.CreateParameter();
  18.       sIdParam.ParameterName = "@storeId";
  19.       sIdParam.Value = TenantContext.Current.TenantId.ToString();
  20.       DbParameter qParam = command.CreateParameter();
  21.       qParam.ParameterName = "@quantity";
  22.       qParam.Value = quantity;
  23.       command.Parameters.Add(mIdParam);
  24.       command.Parameters.Add(sIdParam);
  25.       command.Parameters.Add(qParam);
  26.       conn.Open();
  27.       command.ExecuteNonQuery();
  28.    }
  29. }
');