[Secured("AddMovieToStore")]
public void AddMovieToStore(Guid movieId, int quantity)
{
DbProviderFactory providerFactory = DbProviderFactories.
GetFactory(ConfigurationManager.
ConnectionStrings["MoviesDB"].ProviderName);
using (DbConnection conn = providerFactory.CreateConnection())
{
conn.ConnectionString = ConfigurationManager.
ConnectionStrings["MoviesDB"].ConnectionString.ToString();
DbCommand command = conn.CreateCommand();
command.CommandText = "INSERT INTO MoviesToStore " +
"(movieId, storeId, quantity) Values (@movieId, @storeId, @quantity)";
DbParameter mIdParam = command.CreateParameter();
mIdParam.ParameterName = "@movieId";
mIdParam.Value = movieId;
DbParameter sIdParam = command.CreateParameter();
sIdParam.ParameterName = "@storeId";
sIdParam.Value = TenantContext.Current.TenantId.ToString();
DbParameter qParam = command.CreateParameter();
qParam.ParameterName = "@quantity";
qParam.Value = quantity;
command.Parameters.Add(mIdParam);
command.Parameters.Add(sIdParam);
command.Parameters.Add(qParam);
conn.Open();
command.ExecuteNonQuery();
}
}