示例#1
0
        public async Task GetAllUserSecretsAsync(HttpContext Context)
        {
            try
            {
                SqlConnection.Open();
                SqlCommand command = new SqlCommand()
                {
                    Connection  = SqlConnection,
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "[Store].[ReturnAllUserSecrets]"
                };

                if (Context.Request.Query.TryGetValue("StoreUsername", out var StoreUsername))
                {
                    command.Parameters.AddWithValue("@StoreUsername", StoreUsername.ToString());
                }

                SqlDataReader reader = await command.ExecuteReaderAsync().ConfigureAwait(false);

                if (reader.HasRows)
                {
                    ResultTable.Load(reader);
                }

                await reader.CloseAsync().ConfigureAwait(false);

                await reader.DisposeAsync().ConfigureAwait(false);

                await command.DisposeAsync().ConfigureAwait(false);

                await SqlConnection.CloseAsync().ConfigureAwait(false);
            }
            catch (Exception exception)
            {
                if (SqlConnection.State.Equals("Open"))
                {
                    SqlConnection.Close();
                }

                DictionaryLog.Add("Exception", exception.HResult);
                DictionaryLog.Add("Exception Message", exception.Message);
            }
        }
示例#2
0
        public async Task DeleteStoreSecretAsync(EntryTypes EntryType, HttpContext Context)
        {
            try
            {
                SqlConnection.Open();
                SqlCommand command = new SqlCommand()
                {
                    Connection  = SqlConnection,
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "[Store].[DeleteStoreSecret]"
                };

                command.Parameters.AddWithValue("@EntryType", EntryType.GetHashCode());
                command.Parameters.AddRange(QueryParameters(Context));

                SqlDataReader reader = await command.ExecuteReaderAsync().ConfigureAwait(false);

                if (reader.HasRows)
                {
                    ResultTable.Load(reader);
                }

                await reader.CloseAsync().ConfigureAwait(false);

                await reader.DisposeAsync().ConfigureAwait(false);

                await command.DisposeAsync().ConfigureAwait(false);

                await SqlConnection.CloseAsync().ConfigureAwait(false);
            }
            catch (Exception exception)
            {
                if (SqlConnection.State.Equals("Open"))
                {
                    await SqlConnection.CloseAsync();
                }

                DictionaryLog.Add("Exception", exception.HResult);
                DictionaryLog.Add("Exception Message", exception.Message);
            }
        }