Exemplo n.º 1
0
        public async Task Log(string eventType, string details, string ipAddress)
        {
            var auditLogItem = new AuditLogItem
            {
                EventType = eventType,
                Details   = details,
                IpAddress = ipAddress,
                Timestamp = DateTimeOffset.Now
            };

            await _auditLogStorage.LogAsync(auditLogItem);
        }
Exemplo n.º 2
0
        internal async Task LogAsync(AuditLogItem auditLogItem)
        {
            using (var connection = new SqlConnection(_identityOptions.ConnectionString))
            {
                using (var command = new SqlCommand(_insertSql, connection))
                {
                    command.Parameters.Add(new SqlParameter("@Details", auditLogItem.Details));
                    command.Parameters.Add(new SqlParameter("@EventType", auditLogItem.EventType));
                    command.Parameters.Add(new SqlParameter("@IpAddress", auditLogItem.IpAddress));
                    command.Parameters.Add(new SqlParameter("@Timestamp", auditLogItem.Timestamp));

                    await connection.OpenAsync();

                    auditLogItem.Id = (int)await command.ExecuteScalarAsync();
                }
            }
        }