public ImportWizardWindowViewModel(IDialogCoordinator dialogCoordinator, ILogger <ImportWizardWindowViewModel> logger, ImportWizardImportTypeViewModel importTypeVm, ImportWizardCsvSettingsViewModel csvSettingsVm, ImportWizardImportContainerViewModel containerVm, ImportWizardRuleSettingsViewModel ruleVm, ImportWizardLapsWebSettingsViewModel lapsWebVm, ImportWizardImportReadyViewModel importReadyVm, IImportProviderFactory importProviderFactory, IImportResultsViewModelFactory resultsFactory, AuditOptions auditOptions, IEventAggregator eventAggregator, IShellExecuteProvider shellExecuteProvider)
        {
            this.logger                = logger;
            this.dialogCoordinator     = dialogCoordinator;
            this.DisplayName           = Constants.AppName;
            this.dialogCoordinator     = dialogCoordinator;
            this.importProviderFactory = importProviderFactory;
            this.resultsFactory        = resultsFactory;
            this.auditOptions          = auditOptions;
            this.eventAggregator       = eventAggregator;
            this.shellExecuteProvider  = shellExecuteProvider;

            // VM mappings
            this.importTypeVm  = importTypeVm;
            this.csvSettingsVm = csvSettingsVm;
            this.containerVm   = containerVm;
            this.ruleVm        = ruleVm;
            this.lapsWebVm     = lapsWebVm;
            this.importReadyVm = importReadyVm;

            // Bindings
            this.importTypeVm.Bind(t => t.ImportType, OnImportModeChanged);

            // Initial binds
            this.Items.Add(importTypeVm);
            this.UpdateImportModeOnViewModels();
            this.ActiveItem = this.Items.First();
        }
        public static async Task ExecuteTest(Func <ApplicationContext, AuditOptions, Task> action)
        {
            var auditOptions = new AuditOptions
            {
                CurrentDateTime = () => new DateTime(2000, 1, 1, 1, 0, 0),
                TransactionId   = () => "7ae1f103-554b-4891-bc1e-4051ccc718b8",
                User            = () => "TestUser",
                Client          = () => "TestApp"
            };

            var serviceProvider = new ServiceCollection()
                                  .RegisterEntityFrameworkAuditing(ServiceLifetime.Singleton, options =>
            {
                options.CurrentDateTime = auditOptions.CurrentDateTime;
                options.TransactionId   = auditOptions.TransactionId;
                options.User            = auditOptions.User;
                options.Client          = auditOptions.Client;
            })
                                  .AddDbContext <ApplicationContext>(options => { options.UseSqlite("DataSource=:memory:"); })
                                  .BuildServiceProvider();

            var context = serviceProvider.GetService <ApplicationContext>();

            context.Database.OpenConnection();
            context.Database.EnsureCreated();

            await action(context, auditOptions);

            context.Database.EnsureDeleted();
            context.Database.CloseConnection();
        }
Exemple #3
0
 public AuditEventProcessor(ILogger <AuditEventProcessor> logger, ITemplateProvider templates, IEnumerable <INotificationChannel> notificationChannels, IHttpContextAccessor httpContextAccessor, IOptionsSnapshot <AuditOptions> auditSettings)
 {
     this.logger               = logger;
     this.templates            = templates;
     this.httpContextAccessor  = httpContextAccessor;
     this.notificationChannels = notificationChannels;
     this.auditSettings        = auditSettings.Value;
 }
 public NotificationSubscriptionProvider(AuditOptions audit, IEventAggregator eventAggregator)
 {
     this.audit           = audit;
     this.eventAggregator = eventAggregator;
     this.eventAggregator.Subscribe(this);
     this.Subscriptions = new BindableCollection <SubscriptionViewModel>();
     this.Rebuild();
 }
 public void Audit(AuditOptions audit, string system, string component, string text, int eventId)
 {
     EventLogEntryType translatedEntryType;
     if (audit == AuditOptions.Succes)
         translatedEntryType = EventLogEntryType.SuccessAudit;
     else
         translatedEntryType = EventLogEntryType.FailureAudit;
     eventLogWriter.WriteLog(translatedEntryType, system, component, text, eventId);
 }
        public static ProccessChangeTrackerResult ProccessChangeTracker(ChangeTracker changeTracker, AuditOptions auditOptions = null)
        {
            if (auditOptions == null)
            {
                auditOptions = new AuditOptions();
            }

            Task <ProccessChangeTrackerResult> task = ProccessChangeTrackerAsync(changeTracker, auditOptions);

            task.Wait();

            return(task.Result);
        }
        public override async Task <bool> ReportPackageSourceAudit()
        {
            if (!AuditOptions.ContainsKey("GitHubReportOwner") || !AuditOptions.ContainsKey("GitHubReportName") || !AuditOptions.ContainsKey("GitHubToken"))
            {
                throw new ArgumentException("The GitHubReportOwner, GitHubReportName, and GitHubReportOwner audit options must be present.");
            }
            if (AuditOptions.ContainsKey("GitHubReportTitle"))
            {
                IssueTitle = (string)AuditOptions["GitHubReportTitle"];
            }
            else
            {
                IssueTitle = string.Format("[DevAudit] {2} audit on {0} {1}", DateTime.UtcNow.ToShortDateString(), DateTime.UtcNow.ToShortTimeString(), Source.PackageManagerLabel);
            }
            GitHubClient client;

            client             = new GitHubClient(new ProductHeaderValue("DevAudit"));
            client.Credentials = new Credentials((string)AuditOptions["GitHubToken"]);
            Repository repository;

            try
            {
                repository = await client.Repository.Get((string)AuditOptions["GitHubReportOwner"], (string)AuditOptions["GitHubReportName"]);
            }
            catch (Exception)
            {
                AuditEnvironment.Warning("Could not get repository {0}/{1}.", (string)AuditOptions["GitHubReportOwner"], (string)AuditOptions["GitHubReportName"]);
            }
            NewIssue issue = new NewIssue(IssueTitle);

            BuildPackageSourceAuditReport();
            issue.Body = IssueText.ToString();
            try
            {
                Issue i = await client.Issue.Create((string)AuditOptions["GitHubReportOwner"], (string)AuditOptions["GitHubReportName"], issue);

                AuditEnvironment.Info("Created issue #{0} {1} in GitHub repository {2}/{3}.", i.Number, IssueTitle, (string)AuditOptions["GitHubReportOwner"], (string)AuditOptions["GitHubReportName"]);
            }
            catch (AggregateException ae)
            {
                AuditEnvironment.Error(ae, "Error creating new issue for repository {0}/{1}.", (string)AuditOptions["GitHubReportOwner"], (string)AuditOptions["GitHubReportName"]);
                return(false);
            }
            catch (Exception e)
            {
                AuditEnvironment.Error(e, "Error creating new issue for repository {0}/{1}.", (string)AuditOptions["GitHubReportOwner"], (string)AuditOptions["GitHubReportName"]);
                return(false);
            }
            return(true);
        }
Exemple #8
0
 public AuditingViewModel(AuditOptions model,
                          INotificationChannelDefinitionsViewModelFactory <PowershellNotificationChannelDefinition, PowershellNotificationChannelDefinitionViewModel> psFactory,
                          INotificationChannelDefinitionsViewModelFactory <SmtpNotificationChannelDefinition, SmtpNotificationChannelDefinitionViewModel> smtpFactory,
                          INotificationChannelDefinitionsViewModelFactory <WebhookNotificationChannelDefinition, WebhookNotificationChannelDefinitionViewModel> whFactory,
                          INotificationChannelSelectionViewModelFactory notificationChannelSelectionViewModelFactory
                          )
 {
     this.model       = model;
     this.psFactory   = psFactory;
     this.smtpFactory = smtpFactory;
     this.whFactory   = whFactory;
     this.notificationChannelSelectionViewModelFactory = notificationChannelSelectionViewModelFactory;
     this.DisplayName = "Auditing";
 }
        public void Audit(AuditOptions audit, string system, string component, string text, int eventId)
        {
            EventLogEntryType translatedEntryType;

            if (audit == AuditOptions.Succes)
            {
                translatedEntryType = EventLogEntryType.SuccessAudit;
            }
            else
            {
                translatedEntryType = EventLogEntryType.FailureAudit;
            }
            eventLogWriter.WriteLog(translatedEntryType, system, component, text, eventId);
        }
        public IQServerReporter(PackageSource source) : base(source)
        {
            if (!AuditOptions.ContainsKey("IQServerUrl") || !AuditOptions.ContainsKey("IQServerUser") || !AuditOptions.ContainsKey("IQServerPass") || !AuditOptions.ContainsKey("IQServerAppId"))
            {
                throw new ArgumentException("The IQServerUrl, IQServerUser, IQServerPass, IQServerAppId audit options must all be present.");
            }
            IQServerUrl   = (Uri)AuditOptions["IQServerUrl"];
            IQServerUser  = (string)AuditOptions["IQServerUser"];
            IQServerPass  = (string)AuditOptions["IQServerPass"];
            IQServerAppId = (string)AuditOptions["IQServerAppId"];
            HttpClient    = CreateHttpClient();
            var byteArray = Encoding.ASCII.GetBytes($"{IQServerUser}:{IQServerPass}");

            HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
                                                                                           Convert.ToBase64String(byteArray));
            AuditEnvironment.Info("Authenticating with IQ Server user {0}.", IQServerUser);
        }
            private static async Task <List <Audit> > OnAfterSaveChanges(this DbContext context,
                                                                         List <AuditEntry> auditEntries, AuditOptions options)
            {
                if (auditEntries == null || auditEntries.Count == 0)
                {
                    return(new List <Audit>());
                }

                var transactionId      = options.TransactionId();
                var serializerSettings = options.JsonSerializerSettings;

                var result = new List <EntityEntry <Audit> >();

                foreach (var auditEntry in auditEntries)
                {
                    // Get the final value of the temporary properties
                    foreach (var prop in auditEntry.TemporaryProperties)
                    {
                        if (prop.Metadata.IsPrimaryKey())
                        {
                            auditEntry.KeyValues[prop.Metadata.GetColumnName()] = prop.CurrentValue;
                        }
                        else
                        {
                            auditEntry.Changes[prop.Metadata.GetColumnName()] = new AuditEntry.Change
                            {
                                NewValue = prop.CurrentValue
                            }
                        }
                    }
                }
                ;

                // Group together audit changes for the same table/key combination (e.g. owned entities which initially come through as distinct changes)
                var grouped = auditEntries.GroupBy(x => new
                {
                    x.TableName, KeyValues = JsonConvert.SerializeObject(x.KeyValues, serializerSettings), x.Action,
                    x.Client, x.CreateBy, x.CreateDate
                });

                foreach (var group in grouped)
                {
                    if (group.Count() > 1)
                    {
                        result.Add(context.Set <Audit>().Add(new Audit
                        {
                            TableName  = group.Key.TableName,
                            Action     = group.Key.Action,
                            Client     = group.Key.Client,
                            CreateDate = group.Key.CreateDate,
                            CreatedBy  = group.Key.CreateBy,
                            RowId      = group.Key.KeyValues,
                            Data       = JsonConvert.SerializeObject(
                                group.SelectMany(x => x.Changes).ToDictionary(pair => pair.Key, pair => pair.Value),
                                serializerSettings),
                            TransactionId = transactionId
                        }));
                    }
                    else
                    {
                        // Save the Audit entry
                        result.Add(context.Set <Audit>()
                                   .Add(group.First().ToAuditItem(transactionId, serializerSettings)));
                    }
                }

                await context.SaveChangesAsync();

                return(result.Select(x => x.Entity).ToList());
            }
Exemple #12
0
        public override async Task <bool> ReportPackageSourceAudit()
        {
            if (!this.AuditOptions.ContainsKey("GitLabReportUrl") || !this.AuditOptions.ContainsKey("GitLabReportName") || !this.AuditOptions.ContainsKey("GitLabToken"))
            {
                throw new ArgumentException("A required audit option for the GitLab environment is missing.");
            }
            HostUrl     = (string)this.AuditOptions["GitLabReportUrl"];
            Token       = (string)this.AuditOptions["GitLabToken"];
            ProjectName = (string)this.AuditOptions["GitLabReportName"];
            GitLabClient client = null;

            try
            {
                this.AuditEnvironment.Info("Connecting to project {0} at {1}", ProjectName, HostUrl);
                client = new GitLabClient(HostUrl, Token);
                IEnumerable <Project> projects = await client.Projects.Owned();

                Project = projects.Where(p => p.Name == ProjectName).FirstOrDefault();
                this.AuditEnvironment.Info("Connected to project {0}.", Project.PathWithNamespace);
            }
            catch (AggregateException ae)
            {
                AuditEnvironment.Error(ae, "Could not get project {0} at url {1}.", ProjectName, HostUrl);
                return(false);
            }
            catch (Exception e)
            {
                AuditEnvironment.Error(e, "Could not get project {0} at url {1}.", ProjectName, HostUrl);
                return(false);
            }
            if (Project == null)
            {
                AuditEnvironment.Error("Could not find the project {0}.", Project.Name);
                return(false);
            }
            if (!Project.IssuesEnabled)
            {
                AuditEnvironment.Error("Issues are not enabled for the project {0}/{1}.", Project.Owner, Project.Name);
                return(false);
            }
            if (AuditOptions.ContainsKey("GitLabReportTitle"))
            {
                IssueTitle = (string)AuditOptions["GitLabReportTitle"];
            }
            else
            {
                IssueTitle = string.Format("[DevAudit] {2} audit on {0} {1}", DateTime.UtcNow.ToShortDateString(), DateTime.UtcNow.ToShortTimeString(), Source.PackageManagerLabel);
            }
            BuildPackageSourceAuditReport();
            try
            {
                IssueCreate ic = new IssueCreate
                {
                    ProjectId   = Project.Id,
                    Title       = IssueTitle,
                    Description = IssueText.ToString()
                };
                Issue issue = await client.Issues.CreateAsync(ic);

                if (issue != null)
                {
                    AuditEnvironment.Success("Created issue #{0} '{1}' in GitLab project {2}/{3} at host url {4}.", issue.IssueId, issue.Title, Project.Owner, ProjectName, HostUrl);
                    return(true);
                }
                else
                {
                    AuditEnvironment.Error("Error creating new issue for project {0} at host url {1}. The issue object is null.", ProjectName, HostUrl);
                    return(false);
                }
            }
            catch (AggregateException ae)
            {
                AuditEnvironment.Error(ae, "Error creating new issue for project {0} at host url {1}.", ProjectName, HostUrl);
                return(false);
            }
            catch (Exception e)
            {
                AuditEnvironment.Error(e, "Error creating new issue for project {0} at host url {1}.", ProjectName, HostUrl);
                return(false);
            }
        }
Exemple #13
0
 public HttpContextAuditDataService(IHttpContextAccessor httpContextAccessor, IOptions <AuditOptions> auditOptions)
 {
     _httpContextAccessor = httpContextAccessor;
     _auditOptions        = auditOptions.Value;
 }
        public static async Task <ProccessChangeTrackerResult> ProccessChangeTrackerAsync(ChangeTracker changeTracker, AuditOptions auditOptions = null, CancellationToken cancellationToken = default)
        {
            if (auditOptions == null)
            {
                auditOptions = new AuditOptions();
            }

            List <AuditObjectData> dbAuditDataList = new List <AuditObjectData>();
            bool requiresCustomBatch = false;

            foreach (EntityEntry entry in changeTracker.Entries())
            {
                if (entry.Entity.GetType().GetCustomAttributes(typeof(AuditIgnoreAttribute), true).Any())
                {
                    continue;
                }

                switch (entry.State)
                {
                case Microsoft.EntityFrameworkCore.EntityState.Added:
                {
                    AuditObjectData auditData;

                    if (entry.IsKeySet)
                    {
                        auditData = new AuditObjectData(
                            actionType: ActionTypes.Add,
                            objectType: entry.Entity.GetType().Name,
                            objectIdentifier: entry.GetPrimaryKey(),
                            objectMetadata: entry.GetMetadata());
                    }
                    else
                    {
                        PropertyEntry objectIdentifierProperty = entry.Metadata.FindPrimaryKey().Properties
                                                                 .Select(x => entry.Property(x.Name))
                                                                 .FirstOrDefault();

                        auditData = new AuditObjectData(
                            actionType: ActionTypes.Add,
                            objectType: entry.Entity.GetType().Name,
                            objectIdentifierProperty: objectIdentifierProperty,
                            objectMetadata: entry.GetMetadata());

                        requiresCustomBatch = true;
                    }

                    dbAuditDataList.Add(auditData);

                    break;
                }

                case Microsoft.EntityFrameworkCore.EntityState.Modified:
                {
                    AuditObjectData auditData = new AuditObjectData(
                        actionType: ActionTypes.Update,
                        objectType: entry.Entity.GetType().Name,
                        objectIdentifier: entry.GetPrimaryKey(),
                        objectMetadata: entry.GetMetadata(onlyModified: true));

                    dbAuditDataList.Add(auditData);

                    break;
                }

                case Microsoft.EntityFrameworkCore.EntityState.Deleted:
                {
                    if (auditOptions.AuditCascadeDelete)
                    {
                        IEnumerable <AuditObjectData> cascadeDeleteAuditData = await CascadeDelete(entry, changeTracker, cancellationToken);

                        dbAuditDataList.AddRange(cascadeDeleteAuditData);
                    }

                    AuditObjectData auditData = new AuditObjectData(
                        actionType: ActionTypes.Delete,
                        objectType: entry.Entity.GetType().Name,
                        objectIdentifier: entry.GetPrimaryKey(),
                        objectMetadata: entry.GetMetadata());

                    dbAuditDataList.Add(auditData);

                    break;
                }
                }
            }

            return(new ProccessChangeTrackerResult(
                       requiresCustomBatch: requiresCustomBatch,
                       auditObjectData: dbAuditDataList));
        }
        public override Task <bool> ReportPackageSourceAudit()
        {
            if (!AuditOptions.ContainsKey("BitBucketReportAccount") || !AuditOptions.ContainsKey("BitBucketReportName") || !AuditOptions.ContainsKey("BitBucketKey"))
            {
                throw new ArgumentException("The BitBucketReportAccount, BitBucketReportName, and BitBucketReportKey audit options must be present.");
            }
            string key = (string)AuditOptions["BitBucketKey"];

            string[] k = key.Split('|');
            if (k.Count() != 2)
            {
                throw new ArgumentException("The BitBucketReportKey audit option must have the format consumer_key|secret.");
            }
            string consumer = k[0], secret = k[1];
            string account    = (string)AuditOptions["BitBucketReportAccount"];
            string repository = (string)AuditOptions["BitBucketReportName"];

            if (AuditOptions.ContainsKey("BitBucketReportTitle"))
            {
                IssueTitle = (string)AuditOptions["BitBucketReportTitle"];
            }
            else
            {
                IssueTitle = string.Format("[DevAudit] {0} audit on {1} {2}", Source.PackageManagerLabel, DateTime.UtcNow.ToShortDateString(), DateTime.UtcNow.ToShortTimeString());
            }
            SharpBucketV2 sharp_bucket = new SharpBucketV2();

            sharp_bucket.OAuth2LeggedAuthentication(consumer, secret);
            RepositoriesEndPoint repository_endpoint = sharp_bucket.RepositoriesEndPoint(account, repository);
            IssuesResource       r;

            try
            {
                r = repository_endpoint.IssuesResource();
            }
            catch (Exception e)
            {
                AuditEnvironment.Error(e, "Could not get issues resource for repository {0}/{1}.", account, repository);
                return(Task.FromResult(false));
            }
            BuildPackageSourceAuditReport();
            Issue issue = new Issue()
            {
                title    = IssueTitle,
                content  = IssueText.ToString(),
                status   = "new",
                priority = "major",
                kind     = "bug"
            };

            try
            {
                Issue i = r.PostIssue(issue);
                if (i == null)
                {
                    AuditEnvironment.Error("Could not post issue to repository {0}/{1}.", account, repository);
                    return(Task.FromResult(false));
                }
                else
                {
                    AuditEnvironment.Success("Created issue {0} at {1}.", i.title, i.resource_uri);
                }
            }
            catch (Exception e)
            {
                AuditEnvironment.Error(e, "Could not post issue to repository {0}/{1}.", account, repository);
                return(Task.FromResult(false));
            }

            return(Task.FromResult(true));
        }
Exemple #16
0
 public static bool CheckAttributeOnClassLevel(Type type, AuditOptions options)
 {
     return(true);
 }
 public AuditDbContext(DbContextOptions <AuditDbContext> options, IAuditSubjectDataService auditSubjectDataService, IOptions <AuditOptions> auditOptions) : base(options)
 {
     _auditSubjectDataService = auditSubjectDataService;
     _auditOptions            = auditOptions.Value;
 }
 public DefaultAuditSubjectService(IOptions <AuditOptions> auditOptions)
 {
     _auditOptions = auditOptions.Value;
 }
            private static List <AuditEntry> OnBeforeSaveChanges(this DbContext context, AuditOptions options)
            {
                context.ChangeTracker.DetectChanges();
                var auditEntries = new List <AuditEntry>();

                foreach (var entry in context.ChangeTracker.Entries())
                {
                    if (entry.State == EntityState.Detached || entry.State == EntityState.Unchanged)
                    {
                        continue;
                    }

                    var auditEntry = new AuditEntry(entry)
                    {
                        TableName  = entry.Metadata.GetTableName(),
                        CreateBy   = options.User(),
                        Client     = options.Client(),
                        CreateDate = options.CurrentDateTime(),
                        Action     = entry.State.ToString()
                    };
                    auditEntries.Add(auditEntry);

                    foreach (var property in entry.Properties)
                    {
                        if (property.IsTemporary)
                        {
                            // value will be generated by the database, get the value after saving
                            auditEntry.TemporaryProperties.Add(property);
                            continue;
                        }

                        var propertyName = property.Metadata.GetColumnName();
                        if (property.Metadata.IsPrimaryKey())
                        {
                            auditEntry.KeyValues[propertyName] = property.CurrentValue;
                            continue;
                        }

                        switch (entry.State)
                        {
                        case EntityState.Added:
                            auditEntry.Changes[propertyName] = new AuditEntry.Change
                            {
                                NewValue = property.CurrentValue
                            };
                            break;

                        case EntityState.Deleted:
                            auditEntry.Changes[propertyName] = new AuditEntry.Change
                            {
                                OldValue = property.OriginalValue
                            };
                            break;

                        case EntityState.Modified:
                            if (property.IsModified)
                            {
                                auditEntry.Changes[propertyName] = new AuditEntry.Change
                                {
                                    OldValue = property.OriginalValue,
                                    NewValue = property.CurrentValue
                                }
                            }
                            ;

                            break;
                        }
                    }
                }

                return(auditEntries.ToList());
            }
Exemple #20
0
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            if (context.HttpContext.Items.TryGetValue(AUDIT_PROCCESSINT_KEY, out object auditProccessing))
            {
                await next();

                return;
            }

            context.HttpContext.Items.Add(AUDIT_PROCCESSINT_KEY, null);

            ActionExecutedContext resultContext = await next();

            ControllerActionDescriptor actionDescriptor = ((ControllerActionDescriptor)context.ActionDescriptor);

            if (actionDescriptor.MethodInfo.GetCustomAttributes(true).Any(x => x.GetType() == typeof(AuditIgnoreAttribute)))
            {
                return;
            }

            if (!actionDescriptor.MethodInfo.CustomAttributes.Any(x => x.AttributeType == typeof(AuditAttribute)) &&
                actionDescriptor.ControllerTypeInfo.GetCustomAttributes(true).Any(x => x.GetType() == typeof(AuditIgnoreAttribute)))
            {
                return;
            }

            IAuditLogger auditLogger  = context.HttpContext.RequestServices.GetRequiredService <IAuditLogger>();
            AuditOptions auditOptions = context.HttpContext.RequestServices.GetRequiredService <IOptions <AuditOptions> >().Value;

            KeyValuePair <string, object> objectIdentifierResult;

            AuditObjectIdentifierKey objectIdentitiferKey = actionDescriptor.MethodInfo.GetCustomAttribute <AuditObjectIdentifierKey>();

            if (objectIdentitiferKey != null)
            {
                objectIdentifierResult = resultContext.RouteData.Values
                                         .Where(x => x.Key == objectIdentitiferKey.ObjectKey)
                                         .SingleOrDefault();
            }
            else
            {
                objectIdentifierResult = resultContext.RouteData.Values
                                         .Where(x => x.Key != "area")
                                         .Where(x => x.Key != "controller")
                                         .Where(x => x.Key != "action")
                                         .LastOrDefault();
            }

            string objectIdentifier = null;

            if (objectIdentifierResult.Value != null)
            {
                objectIdentifier = objectIdentifierResult.Value.ToString();
            }

            switch (resultContext.Result)
            {
            case OkObjectResult _:
            {
                OkObjectResult okObjectResult = (OkObjectResult)resultContext.Result;

                AuditObjectData auditObject = new AuditObjectData(
                    actionType: ActionTypes.Get,
                    objectType: okObjectResult.Value.GetType().GetNameWithGeneric(),
                    objectIdentifier: objectIdentifier,
                    objectMetadata: JsonConvert.SerializeObject(okObjectResult.Value));

                await auditLogger.LogAsync(auditObject);

                break;
            }

            case ViewResult _:
            {
                ViewResult viewResult = (ViewResult)resultContext.Result;

                List <AuditObjectData> auditObjects = new List <AuditObjectData>();

                if (viewResult.Model != null)
                {
                    AuditObjectData auditObject = new AuditObjectData(
                        actionType: ActionTypes.Get,
                        objectType: viewResult.GetType().Name,
                        objectIdentifier: objectIdentifier,
                        objectMetadata: JsonConvert.SerializeObject(viewResult.Model));

                    auditObjects.Add(auditObject);
                }

                if (auditOptions.AuditViewData && viewResult.ViewData.Any())
                {
                    AuditObjectData auditObject = new AuditObjectData(
                        actionType: ActionTypes.Get,
                        objectType: viewResult.ViewData.GetType().Name,
                        objectIdentifier: objectIdentifier,
                        objectMetadata: JsonConvert.SerializeObject(viewResult.ViewData));

                    auditObjects.Add(auditObject);
                }

                await auditLogger.LogAsync(auditObjects);

                break;
            }

            case BadRequestObjectResult _:
            {
                if (!auditOptions.AuditBadRequest)
                {
                    break;
                }

                BadRequestObjectResult badRequestObjectResult = (BadRequestObjectResult)resultContext.Result;

                AuditObjectData auditObject = new AuditObjectData(
                    actionType: ActionTypes.BadRequest,
                    objectType: badRequestObjectResult.Value.GetType().Name,
                    objectIdentifier: objectIdentifier,
                    objectMetadata: JsonConvert.SerializeObject(badRequestObjectResult.Value));

                await auditLogger.LogAsync(auditObject);

                break;
            }

            case FileContentResult _:
            {
                FileContentResult fileContentResult = (FileContentResult)resultContext.Result;

                AuditObjectData auditObjectData = new AuditObjectData(
                    actionType: ActionTypes.Get,
                    objectType: resultContext.Result.GetType().Name,
                    objectIdentifier: objectIdentifier,
                    objectMetadata: JsonConvert.SerializeObject(new { fileContentResult.ContentType, fileContentResult.FileDownloadName }));

                await auditLogger.LogAsync(auditObjectData);

                break;
            }

            case RedirectResult _:
            case RedirectToActionResult _:
            case RedirectToPageResult _:
            case RedirectToRouteResult _:
            case LocalRedirectResult _:
            {
                break;
            }

            default:
            {
                if (resultContext.Result != null)
                {
                    AuditObjectData auditObject = new AuditObjectData(
                        actionType: ActionTypes.Get,
                        objectType: resultContext.Result.GetType().Name,
                        objectIdentifier: objectIdentifier,
                        objectMetadata: null);

                    await auditLogger.LogAsync(auditObject);
                }

                break;
            }
            }
        }